...

View Full Version : Last link rolled over maintains picture (instead of switching back to default)



jonw118
05-12-2009, 03:04 AM
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:

<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"

<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:

<a href="#" onMouseOver="swap(this,'showperson','blue')"></a>

Thanks again so much for any help!

Sphynx
05-12-2009, 07:57 AM
Remove this line:

link.onmouseout = swapBack;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum