Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Last link rolled over maintains picture (instead of switching back to default)

    I'd really appreciate any help!

    I have a script that has several links and when you rollover the link it changes a main picture to be view as an image. But, when you no longer mouse over the link, it switches back to the default image.

    I'd like for the last link that was rolled over to stay enlarged as the main pic until you roll over a different link.

    Here's the current script...

    In the head:
    Code:
    <SCRIPT TYPE="text/javascript">
    <!--
    
    // var image information object
    var mloi=new Object();
    
    // set the image for swapping
    function setswap()
    {
    if (! document.images)return;
    var imgInfo=new Object();
    imgInfo.defaultImg = new Image();
    imgInfo.defaultImg.src = document.images[arguments[0]].src;
    imgInfo.opts = new Object();
    for (var i=1; i < arguments.length; i=i+2)
       {
       imgInfo.opts[arguments[i]]=new Image();
       imgInfo.opts[arguments[i]].src = arguments[i+1];
       }
    mloi[arguments[0]] = imgInfo;
    }
    
    // set up the link for swapping
    function swap(link,imgName,optName)
    {
    if (! document.images)return;
    if (! link.swapReady)
       {   
       link.imgName    = imgName;
       link.onmouseout = swapBack;
       link.swapReady  = true;
       }
    document.images[imgName].src=mloi[imgName].opts[optName].src;
    }
    
    function swapBack()
       {document.images[this.imgName].src=mloi[this.imgName].defaultImg.src}
    
    //-->
    </SCRIPT>
    Displays the "main image"
    Code:
    <img 
       SRC="1.jpg"
       WIDTH=284 HEIGHT=230 ALT=""
       NAME="showperson"
        />
    <SCRIPT TYPE="text/javascript">
    <!--
    setswap("showperson",
       blue', 'blue.jpg',
       'pink',      'pink.jpg',
       'white',      'white.jpg'
       );
    //-->
    </SCRIPT>
    Displays the link:
    Code:
    <a href="#" onMouseOver="swap(this,'showperson','blue')"></a>
    Thanks again so much for any help!

  • #2
    New Coder
    Join Date
    Mar 2006
    Posts
    23
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Remove this line:

    link.onmouseout = swapBack;


  •  

    Posting Permissions

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