OnmouseMove not work with SetTimeOut and Alerts in Chome

Posted by Diogo Fernandes on Stack Overflow See other posts from Stack Overflow or by Diogo Fernandes
Published on 2010-04-05T12:19:58Z Indexed on 2010/04/05 12:23 UTC
Read the original article Hit count: 420

Filed under:
|
|
|

What's wrong with this code? It works in IE and FireFox, but Chrome does not work. The idea is that the function fnTimeOut will be triggered in 5 seconds after onmousemove. It´s ok. But when, in Chrome, I click on the button "ok" to function fnAlert is triggered instantly. It should be shot just 5 seconds after I move the mouse ... help me please.


<input type="button" onclick="alert(1);" value="ok">


<script>
document.onmousemove = fnTimeOut;

var t = null;

function fnAlert()
{
    alert(2);
}

function fnTimeOut()
{
    clearTimeout( t );
    t = setTimeout( fnAlert, 5000 );
}
</script>

© Stack Overflow or respective owner

Related posts about onmousemove

Related posts about settimeout