Click to See Complete Forum and Search --> : mouseover time


IxxI
05-15-2003, 06:23 AM
Is there a way to check how long a mouse has been over something and only perform a function after it has been over it for a certain amount of time. So if it's over it for half the time and then moved off nothing happens??

IxxI

Gollum
05-15-2003, 06:37 AM
you can use window.setTimeout and window.clearTimeout.

like this...

<html>
<head>
<script language="Javascript">
function Action()
{
alert('well, do stuff!');
}
</script>
</head>
<body>
<div onmouseover="this.timeoutID=window.setTimeout('Action();',3000);" onmouseout="window.clearTimeout(this.timeoutID);">
...
</div>
</body>
</html>