Jon
Jon

Reputation: 2085

IE 8: JS call to new Image() fails when the code is run in a popup window

I've run into a strange Internet Explorer 8 issue.

I have the following Javascript:

var img = new Image();
img.src = "http://something.com/images/something.gif";

It works just fine when I'm running it in its own window but when it's run in a pop up window it fails saying 'Image is not defined'. This only happens in Internet Explorer. I'm curious to know if anyone has encountered this and how I might work around it.

Thanks!

Upvotes: 1

Views: 4257

Answers (1)

Andy E
Andy E

Reputation: 344585

If you don't get it working, you can resort to creating the img tag with createElement instead.

var img = document.createElement("img");
img.src = "http://something.com/images/something.gif";

Upvotes: 4

Related Questions