views:

621

answers:

1

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!

+3  A: 

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";
Andy E
I ended up referencing an image I put on the page with the parameters I needed.
Jon
Ah, I didn't realise you wouldn't be adding it to the DOM, that was going to be my other suggestion. At least you got it working :)
Andy E