定时器插件为您提供了一种监视用户活动的方法。监视-鼠标静止,鼠标滚动滚轮和使用键盘时的状态。
有两种方法来实例化。静态的,或是在一个元素上的。元素绑定的定时器将只关注事件的内部。你可能只是想让页面动态,在这种情况下,你可以在 document
, document.documentElement
, 和 document.body
中设置你的计时器。
实例化返回jQuery链接。
使用实例
$(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 }); });