Idle plugin provides you a way to monitor user activity with a page.Idle is defined by not moving the mouse, scrolling the mouse wheel and using the keyboard.
There are two ways to instantiate. Either statically, or on an element. Element bound timers will only watch for events inside of them. You may just want page-level activity, in which case you may set up your timers on document
, document.documentElement
, and document.body
. Instantiate returns jQuery for chaining.
Example usage
$(function() // Set idle time $( document ).idleTimer( 5000 );});$(function() $( document ).on( "idle.idleTimer", function(event, elem, obj) // function you want to fire when the user goes idle }); $( document ).on( "active.idleTimer", function(event, elem, obj, triggerevent) // function you want to fire when the user becomes active again });});