Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Nov 2005
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post

    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

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    You'd need to assign an id attribute to each of them and then address them by
    document.getElementById() method.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Nov 2005
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Perhaps
    Code:
    document.getElementById('...').src='path-to-image';document.getElementById('caption1').innerHTML='Boilerhouse'
    work.
    BTW, what's this 'caption1' element?
    Last edited by abduraooft; 10-02-2008 at 03:46 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Nov 2005
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •