gpt4 book ai didi

带有计时器的php ajax自动注销

转载 作者:行者123 更新时间:2023-11-30 08:16:06 25 4
gpt4 key购买 nike

<script type="text/javascript">
var t;
function startTimer(){
t=setTimeout("document.location='../login/logout.php'", 50000);
}

function stopTimer(){
clearTimeout(t);
}
</script>

这是我的自动注销脚本,

我想显示倒数计时器,如何创建和显示计时器,

我还想在用户点击页面正文时激活

当系统空闲时,计时器也应该重置然后重新启动,

如何制作,

(计时器应该显示,即 计时器应该在人们不接触系统时运行,

如果用户触摸系统,则计数器应该重新启动)

最佳答案

使用这个函数:

function timer(elem, starttime, endtime, speed, funktion, count) {
if (!endtime) endtime = 0;
if (!starttime) starttime = 10;
if (!speed) speed = 1;
speed = speed * 1000;
if ($(elem).html() || $(elem).val()) {
if (count == "next" && starttime > endtime) starttime--;
else if (count == "next" && starttime < endtime) starttime++;
if ($(elem).html()) $(elem).html(starttime);
else if ($(elem).val()) $(elem).val(starttime);
if (starttime != endtime && $(elem).html()) setTimeout(function() {
timer(elem, $(elem).html(), endtime, speed / 1000, funktion, 'next');
}, speed);
if (starttime != endtime && $(elem).val()) setTimeout(function() {
timer(elem, $(elem).val(), endtime, speed / 1000, funktion, 'next');
}, speed);
if (starttime == endtime && funktion) funktion();
} else return;
}

Example

timer("#timer", 50, 0, 1, function() {
location.href = "../login/logout.php";
});

关于带有计时器的php ajax自动注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3801935/

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