/ Published in: JavaScript

find idle time in javascript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
var idleTime = 5000; var timeOut = â€; function init() { Event.observe(document.body, ‘mousemove’, resetIdle, true); setIdle(); } function onIdleFunction(){ alert(‘Your browser has been idle for ‘ + (idleTime/1000) +’ seconds.’); } function resetIdle(){ window.clearTimeout( timeOut ); setIdle(); } function setIdle(){ timeOut = window.setTimeout( "onIdleFunction()", idleTime ); } Event.observe(window, ‘load’, init, false);
URL: http://www.andrewsellick.com/67/simple-javascript-idle-state-using-prototype
Comments
