0
votes
document.getElementById("displayImage").getElementsByTagName("img")[0].src = "image2.png"

I seem to remember that for IE, you need to add a <meta> tag of some description, but I can't find which one.

If it helps:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0;

Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR

3.5.30729; .NET CLR 3.0.30729) Timestamp: Tue, 6 Sep 2011 12:23:00 UTC

Message: Object doesn't support this property or method

2
can you supply the part of the html which should be altered? - Walialu
try debugging with the IE developer tools. The error might not really lie where the error console tells you it does. - zatatatata
<div align="center" id="displayImage"> <img id="case" src="<?=$_GET['image']?>"> </div> - joedborg
There's no need for a meta tag for this; the script should work in IE. Without the HTML document, we're shooting in the dark. - Jeremy
Have you tried document.getElementById("case").src = "image2.png"? - punkrockbuddyholly

2 Answers

1
votes

As I mentioned in a comment above, the code is fine; there's no need for a meta tag. I suspect there is some other JavaScript error occurring before the code executes. It's either that, or the elements don't exist in the document when the code executes.

0
votes

try setting the src attribute for the image like this

var image = document.getElementById("displayImage").getElementsByTagName("img")[0];
image.setAttribute("src",path);