Results 1 to 2 of 2

Thread: Image Swap on text link

  1. #1
    Join Date
    Apr 2010
    Posts
    2

    Image Swap on text link

    I am building a website and have an issue that is driving me NUTS!

    I have set an image swap on the page when the viewer hovers over a link using the following code:

    <a href="" onClick="document.main.src='image.png';">image swap text
    </a>

    It is functioning to swap the image , but ONLY on the moment of the click. Afterward, the original image comes back onscreen. I would like to make it so that the new image stays unless a different image swap link is clicked. I know you can succeed in doing this using another div and adding an image swap behavior, but I would prefer to have the text link work as desired. Anyone have a solution?

  2. #2
    BIOSTALL Guest

    Link href

    Your link has a blank 'href' attribute which means when the link is clicked the page is just refreshing.

    Either a) set the href to something like 'javascript://' or b) add 'return false;' to the end of your onclick.

    Hope that helps,

    BIOSTALL

Similar Threads

  1. showing text over image in a link
    By ketanco in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 16 May 2008, 11:28 PM

Posting Permissions

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