...

View Full Version : Help: changing text onmouseover script fails in Mozilla



edmonds
10-02-2008, 03:03 PM
hi
i want to swap a main image and its caption with other images when the thumnails are moused over.

the main image id is GRP, the caption text span id is caption1.

the mouseover code in the thumnails is:
onMouseOver="GRP.src='GRP-Plantrooms/GRP-Plantroom3.jpg'; caption1.innerHTML = 'Boilerhouse'"

this works fine for Opera, IE6, 7 but not Mozilla.

In mozilla the images swap but not the text.
Perhaps Mozilla would prefer to use something other than innerHTML?

I have done a lot of searches and tried many variations, none seem to work.

thanks
tom

abduraooft
10-02-2008, 03:39 PM
You'd need to assign an id attribute to each of them and then address them by
document.getElementById() method.

edmonds
10-02-2008, 04:08 PM
yup, tried that many times:
onMouseOver="document.getElementById('caption1').write='Boilerhouse'"
and
onMouseOver="GRP.src='GRP-Plantrooms/GRP-Plantroom1.jpg';document.getElementById('caption1').write='Boilerhouse'"

doesn't work. doesn't work in any browser then.

abduraooft
10-02-2008, 04:15 PM
Perhaps

document.getElementById('...').src='path-to-image';document.getElementById('caption1').innerHTML='Boilerhouse'
work.
BTW, what's this 'caption1' element?

edmonds
10-02-2008, 04:34 PM
thank you thank you thank you!

this now works in all browsers:
onMouseOver="GRP.src='GRP-Plantrooms/GRP-Plantroom2.jpg';document.getElementById('caption1').innerHTML='Sprinkler Pumphouse'"

caption1 is the id of the span that holds the image caption. there is one big image with a caption underneath and 4 thumbnails underneath that. mouseover thumbnails changes main image and caption.

thanks again

tom



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum