gpt4 book ai didi

javascript - session 超时 - 结果以分钟为单位

转载 作者:行者123 更新时间:2023-11-30 09:31:47 25 4
gpt4 key购买 nike

<分区>

var IDLE_TIMEOUT = 2700; //seconds 45min

var _idleSecondsCounter = 0;
document.onclick = function() {
_idleSecondsCounter = 0;
};
document.onmousemove = function() {
_idleSecondsCounter = 0;
};

document.onkeypress = function() {
_idleSecondsCounter = 0;
};
window.setInterval(CheckIdleTime, 1000);

function CheckIdleTime() {
_idleSecondsCounter++;
var oPanel = document.getElementById("SecondsUntilExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
//alert("Your Session Time expired. Please Login.");
document.location.href = "logoff.php";
}
}
<div id='SecondsUntilExpire'></div>

所以从上面我得到的输出是 2699(以秒为单位 = 45 分钟),如果没有事件发生,它会递减(2698..2697..等等),如果有任何事件(鼠标抬起..等)发生它回到2699

但我需要在几分钟内:44:59、44:58 ..等等

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com