Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Change layer image?

  • 16-07-2004 07:44PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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