Results 1 to 2 of 2

Thread: Change div and layer background in netscape 4.75 with javascript

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2002
    Location
    Munich
    Posts
    25

    Question Change div and layer background in netscape 4.75 with javascript

    Hi there,

    is there any possibility to change background-images of a div or a layer in Netscape 4.75 by means of javascript?

    The problem is the following:

    I manage to change the background of a layer (is it possible for divs too??) but the problem is, that I am not able to turn background-repeat = "no-repeat". This is a style - function and I put the style for the layer and for the div. But when I change the background dynamically, it seems to have no effect.....

    What I do is the following:

    I have a Java-Script file containing the following lines in one function:

    document.menuImage.background.src=$img.src;

    in the html - file I have declared the following layer-object:

    <layer height="42" id="menuImage" style="background-repeat:no-repeat;"></layer>

    the image changes properly, but the background-repeat is one.

    Does someone know why? I would really be very grateful

    Thx
    Yours
    Jeb

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    Netscape 4 doesnt work that way. Although you can use the style attribute, it is not supported in the same way as Mozilla.

    Try something like this : -

    Code:
    <html>
    <head>
    <script language="javascript" type="text/javascript">
    function changeBgImage(layerID,urlName){
    document.layers[layerID].bgImage=urlName;
    }
    </script>
    </head>
    <body>
    <layer id="layer1" width="200" height="200" background="http://yourdomain.com/image1.jpg" onMouseOver="javascript:changeBgImage('layer1','http://yourdomain.com/image2.jpg')" onMouseOver="javascript:changeBgImage('layer1','http://yourdomain.com/image1.jpg')">
    </layer>
    </body>
    </html>
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

Posting Permissions

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



Click Here to Expand Forum to Full Width