SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Dec 2001
    Location
    San Diego, CA
    Posts
    617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    test link to swap image

    http://slant.somasandiego.com/home.php?p=swag

    When you use a text link to swap an image, what do you put for the 'href'? If I put '#' then the image swaps no problem, however it will scroll to the top (problem when you are at the bottom of the page). If I put 'javascript:;' like I do for popup windows to open without scrolling to the top of the page, the image doesn't swap (click the green t-shirt, that uses the 'javascript:;')

    Also, if anyone knows a way to swap an image using a drop down menu instead that would be even better. I couldn't figure that out so that is why I am using text links for now.

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    don't use an anchor (<a>) element. Those are for links, not page interactivity. I know what you're thinking, "But if I don't use an <a> tag my users won't get the little hand". That, my friend, is why we have CSS!

    <style>
    span.clicker {
    cursor: pointer;
    }
    </style>

    <span class="clicker" onclick="MM_swapImage('slant1','','img/swag/slant1_green.gif',1)">Green</span>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Addict
    Join Date
    Jul 2001
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this...

    <a href="" onMouseOver="document.MyImage.src='image2.gif';" onMouseOut="document.MyImage.href="image1.gif";">

    text here.

    </a>

    <img src="image1.gif" name="MyImage">


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
  •