1

我正在寻找执行以下行为的 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.
4

1 回答 1

0

这里有一个很好的 jQuery 插件: http ://www.erichynds.com/jquery/creating-a-mint-com-style-idle-logout-timer-using-jquery/ 它可以让你做你想做的事。您可以通过更改参数轻松让它在 10 分钟后更改页面redirectAfter

于 2012-06-27T20:27:02.617 回答