-1
imageObj.onload = function() {

and

imageObj.addEventListener('load', function() {

I want to execute code when image is loaded. I have tried both of above lines but none of its working in edge and safari. In chrome, it's working fine.

TylerH
  • 20,816
  • 57
  • 73
  • 92
Radhika
  • 533
  • 3
  • 20

1 Answers1

0

I made a test with code sample below and looks like these code samples are working with MS Edge.

<!doctype html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var img = new Image();
img.onload = function () {
   alert("image is loaded");
}
img.src = "http://pierre.chachatelier.fr/programmation/images/mozodojo-original-image.jpg";

$(img).appendTo('body');
});
</script>
</head>
<body>
</body>
</html>

Output in MS Edge.

enter image description here

Here is the alternative approach.

<!DOCTYPE html>
<html>
<body>

<img src="C:\Users\panchals\Desktop\image\9.gif" onload="loadImage()" width="100" height="132">

<script>
function loadImage() {
  alert("Image is loaded");
}
</script>

</body>
</html>

You can try to make a test with these code on your side. If issue persist than I suggest you to post your full sample code. We will try to check it.

Deepak-MSFT
  • 9,078
  • 1
  • 9
  • 16