You are here: irt.org | FAQ | JavaScript | Pointer | Q602 [ previous next ]
Try this:
<html> <head> <script language="JavaScript"><!-- if (navigator.appName == 'Netscape') { document.captureEvents(Event.MOUSEMOVE); document.onmousemove = netscapeMouseMove; } function doit() { timerRunning = false; alert('hello world'); } function netscapeMouseMove(e) { if (e.screenX != document.test.x.value && e.screenY != document.test.y.value) { if (timerRunning) { clearTimeout(myTimer); myTimer = setTimeout('doit()',5000); } document.test.x.value = e.screenX; document.test.y.value = e.screenY; } } function microsoftMouseMove() { if (window.event.x != document.test.x.value && window.event.y != document.test.y.value) { if (timerRunning) { clearTimeout(myTimer); myTimer = setTimeout('doit()',5000); } document.test.x.value = window.event.x; document.test.y.value = window.event.y; } } var myTimer = setTimeout('doit()',5000); // invoke doit() after five seconds of mouse inactivity var timerRunning = true; //--></script> </head> <body onMousemove="microsoftMouseMove()"> <form name="test"><input type="hidden" name="x"><input type="hidden" name="y"></form> </body> </html>