Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-02-2008, 02:03 PM   PM User | #1
edmonds
New Coder

 
Join Date: Nov 2005
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
edmonds is an unknown quantity at this point
Help: changing text onmouseover script fails in Mozilla

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
edmonds is offline   Reply With Quote
Old 10-02-2008, 02:39 PM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
You'd need to assign an id attribute to each of them and then address them by
document.getElementById() method.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 10-02-2008, 03:08 PM   PM User | #3
edmonds
New Coder

 
Join Date: Nov 2005
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
edmonds is an unknown quantity at this point
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.
edmonds is offline   Reply With Quote
Old 10-02-2008, 03:15 PM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Perhaps
Code:
document.getElementById('...').src='path-to-image';document.getElementById('caption1').innerHTML='Boilerhouse'
work.
BTW, what's this 'caption1' element?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

Last edited by abduraooft; 10-02-2008 at 03:46 PM..
abduraooft is offline   Reply With Quote
Old 10-02-2008, 03:34 PM   PM User | #5
edmonds
New Coder

 
Join Date: Nov 2005
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
edmonds is an unknown quantity at this point
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
edmonds is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:39 AM.


Advertisement
Log in to turn off these ads.