简体   繁体   English

"当标签空闲或在另一个选项卡上工作时,setInterval停止工作,"

[英]Setinterval is stop working when tab is idle or working on another tab,

I have created a solution for sessiontimeout popup, to check idle time I am using a setInterval as mentioned below我已经为 sessiontimeout 弹出窗口创建了一个解决方案,以检查我正在使用 setInterval 的空闲时间,如下所述

    // Increment the idle time counter every 1 second.
    idleInterval = setInterval(timerIncrement, 2000, (@warningShowDelayMinutes * 60), (@sessionTimeout * 60), @warningTimeLeft);

function timerIncrement(warningShowDelay, sessionTimeout) {
        idleTime++;
        console.log("before dialog open idleTime - :" + idleTime);
        if (idleTime >= warningShowDelay && idleTime <= sessionTimeout) {
            var isWarningPopupOpened = $('#session-expire-warning').dialog('isOpen');
            if (!isWarningPopupOpened) {
                $("#session-expire-warning").dialog("open");
                //console.log("before dialog after idleTime -:" + idleTime);
            }
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM