views:

144

answers:

1

I'm trying to change an image in JavaScript+Prototype by changing the "src" attribute of the element. It works fine in IE, but not in Firefox. I don't get any errors and the script continues executing after this bit executes:

var image = $('toggle');
image.setAttribute("src", "../images/icons/icon_minus.gif");
image.setAttribute("alt", "Minus Symbol");
image.setAttribute("title", "Collapse tree");

What am I doing wrong? How do I make the browser replace the existing image "icon_plus.gif" with "icon_minus.gif"? I'm sure it must be something really obvious but I can't figure out what!

Thanks

A: 

Cant figure out what is wrong, but I believe its possible to do a:

image.src = "../images/icons/icon_minus.gif";

BTW, is the image path absolutely correct?

Salman A
Well I have no idea why that worked, but it did! Thanks!
I created a test Prototype script using the code you posted; it worked perfectly in FireFox. It is possible that FireFox wasn't able to fetch the image when you tested... network problem or something similar.
Salman A