SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Longueuil, QC
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    swapping image (rollover) within div/layers for Netscape4.7

    Ok, I've red all threads about it on the board and nothing works, here's my code for the rollover:

    Code:
    function change_image_layer(image_name, image_src, layer_name)
    {
    
        // Can the browser handle rollovers?
        if (document.images)
        {
            // Is is a DOM-compatible browser?? (Netscape4.x below are NOT)
            if (document.layers)
            {
                // MUST FIX N4.x
                document.layers[layer_name].document.images[image_name].src = image_src;
            }
            else
            {
                document.images[image_name].src = image_src;
            }
        }
    
    }
    Let's say my image is called "submenu2_1" and is within the layer/div "subnav2", here's the code I put :

    Code:
    onMouseOver="change_image_layer('submenu2_1','images/submenu2_1_on.gif','subnav2'); return true;" onMouseOut="change_image_layer('submenu2_1','images/submenu2_1.gif','subnav2'); return true;"
    Now Netscape 4.7 gives me the following error : document.layers[layer_name]

    Please help!

    Thanks

  2. #2
    SitePoint Evangelist Mr. Brownstone's Avatar
    Join Date
    May 2002
    Location
    Relative
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know nothing about Netscape 4.x, but this looks wrong to me:
    Code:
    document.layers[layer_name].document.images[image_name].src = image_src;
    Should that extra document be there?
    Of course, that's just my opinion. I could be wrong.

  3. #3
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not knowing what the html looks like, I made some changes. This works for me.

    <layer id='a'>
    <a href="#" onMouseOver="change_image_layer('b','http://members.aol.com/grassblad/images/background.gif','a'); return true;" onMouseOut="change_image_layer('submenu2_1','images/submenu2_1.gif','subnav2'); return true;"> <img src="<A href="http://members.aol.com/grassblad/images/grassAvatar.jpg">http://members.aol.com/grassblad/images/grassAvatar.jpg" name="b"></a>
    </layer>

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

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