Return to Snippet

Revision: 37417
at December 9, 2010 20:47 by hairajeshk


Initial Code
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);

Initial URL
http://www.andrewsellick.com/67/simple-javascript-idle-state-using-prototype

Initial Description
find idle time in javascript

Initial Title
Idle timeout in Javascript

Initial Tags

                                

Initial Language
JavaScript