Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

document.images array in Firefox

Status
Not open for further replies.

SimonTheSponge

Programmer
Feb 12, 2001
74
GB
Hi

I have a script that I'm migrating from IE to FireFox. Some of my mouseover events do not seem to work. The existing code changed the .src of an image by referring to it as an element in the images array

document.images[n].src = 'newimage.gif'

This code does not appear to work in Firefox/Mozilla ie the image doesn't change. Does anybody know how I would port this toMozilla/W3C code

Cheers
 
I duplicate the name as an id, then

document.getElementById(n).src = 'newimage.gif';

You might try

document.getElementByName(n).src = 'newimage.gif';

but I don't remember if that's compatible in all browsers or not.

Lee
 
Thanks Trollacious,

I've found the problem:

It appears that in firefox, that there is a setting to allow Javascript to "change images
 
If you run your pages through validator.w3.org you'll probably find that the name attribute for images isn't valid. That's why I changed to using the id with the same image swapping function.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top