Thursday, September 17, 2009

Delayed action on Mouseover

Haven't tried this yet, just parked it here till I need to use it.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Page title</title>

<script type="text/javascript">
var c=0;
var t;
var myTimer;
function timedCount()
{
document.getElementById('txt').value=c
c=c+1
t=setTimeout("timedCount()",50)
}

function stopCount()
{
clearTimeout(t)
}

</script>
</head>

<body>
<form>
<input type="button" value="Start count!" onmouseover="var myTimer=setTimeout('timedCount()', 1000);" onmouseout="clearTimeout(myTimer);">
<input type="text" id="txt">
<input type="button" value="Stop count!" onClick="stopCount()">
</form>
</body>
</html>

No comments:

Post a Comment