View Single Post
Old 10-14-2012, 12:24 AM   PM User | #1
MasterAtreu
New to the CF scene

 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
MasterAtreu is an unknown quantity at this point
Adding onmouseout delay to JS.

The below snippet of js is being used to swap 2 imagemaps upon mouseover and then return to original imagemap after mouseout. I am trying to add a delay to the mouseout (so it stays on the second image for 3 seconds before reverting to previous image). So far, I am not having any success in finding where I can implement the delay(). Any help would be greatly appreciated.

JS Code:

[CODE
<script type="text/javascript">
function MapRoll( imgId )
{
var holder = document.images[ imgId ],
map = document.getElementsByName( holder.useMap.replace(/^([^#]*#)(.+)/, "$2" ) )[ 0 ],
areas = map.getElementsByTagName( 'area' /*28632953637269707465726C61746976652E636F6D*/ ),
args = MapRoll.arguments,
targetHolder = document.getElementById( args[ 1 ] ) || holder,
offset = ( targetHolder === holder ? 1 : 2 );
defSrc = targetHolder.src;

for( var i = offset, spot, argLen = args.length; i < argLen; i++ )
{
( spot = areas[ i - offset ] ).imgObj = new Image();
spot.imgObj.src = args[ i ];
spot.onmouseover = spot.onfocus = swap;
spot.onmouseout = spot.onblur = back;
setTimeout(spot.onmouseout, 5000);
}

function swap(){ targetHolder.src = this.imgObj.src; }

function back(){ targetHolder.src = defSrc; }
}
</script>
]

Thanks again!

Last edited by MasterAtreu; 10-14-2012 at 05:06 AM.. Reason: Addition
MasterAtreu is offline   Reply With Quote