空闲插件为您提供了一种使用页面来监视用户活动的方法。通过不移动鼠标,滚动鼠标滚轮和使用键盘来定义它。
有两种实例化方法。 静态地,还是元素上。 元素绑定计时器只会看到他们内部的事件。您可能只想要页面级的活动,其中你可以设置你的计时器 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
});
});