我正在寻找执行以下行为的 jQuery 插件: 1. 查找用户在 10 分钟内不活动。2. 10 分钟后显示警报或灯箱消息。我相信灯箱会更好。3. 再过 5 分钟后,执行一个动作。
My javascript code is :
<script type="text/javascript">
var idleTime = 0;
var activeTime = 0;
var warningFlag = 0;
setInterval(function checkIdle() {
idleTime += 1;
activeTime += 1;
//document.write(idleTime + ' ' + activeTime);
if(idleTime > 5) {
alert("Idle from last 5 seconds!! You have been active for last "+ activeTime);
warningFlag=1;
}
if((idleTime > 10) && (warningFlag==1)) {
alert("Idle from last 10 seconds!! You have been active for last "+ activeTime);
window.location = "www.tinyprints.com";
}
window.onload = resetTimer;
document.onmousemove = resetTimer;
document.onkeypress = resetTimer;
},1000);
function resetTimer() {
idleTime = 0;
}
</script>
But i was thinking to use a jQuery plugin.