Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Change layer image?

Options
  • 16-07-2004 7:44pm
    #1
    Registered Users Posts: 2,013 ✭✭✭


    I have a layer on a page, and I want to be able to change the image in it to 5 alternate pictures depending on which link the viewer clicks. Like thumbnails to open a large version of the thumbnail picture in the layer.

    I'm new to all this layers/javascript stuff and I can't seem to find any help on google or code that works.

    The layer is called Layer0

    i've named the function changeimage, and i'm calling it using 'javascript:changeimage();' which i presume is the right way to do it.

    And the function code..

    <script language="JavaScript" type="text/JavaScript">
    function changeimage(){
    document.Layer0.background.src = 'test2.png';
    }

    I don't quite know what the code line is to change the image.

    Can anyone help?


Comments

  • Registered Users Posts: 1,268 ✭✭✭hostyle


    When you say layers, do you mean the deprecated Netscape LAYER tag or the standard DIV tag?

    If its the latter, then you should try using a standards compliant DOM interface.
    if (document.getElementById) {
      document.getElementById("Layer0").style.background = 'test2.png';
    }
    

    PS. am under influence of alcohol. Above syntax may be wrong.


  • Registered Users Posts: 2,013 ✭✭✭SirLemonhead


    I'm using the standard DIV tag.

    How do I get that code to work when one of the links is clicked? Javascript is still totally new to me.

    Thanks for the help so far though :)


Advertisement