我有以下代码:

t = setTimeout(function () { blah();  }, 900000);

基本上,在加载页面15分钟后,它将调用Blah。

但是,如果在某个时候我显示一个警报()或cenfirst(),那么一旦被驳回,blah()由于某种原因被执行。

据我所知,这仅发生在Safari/Chrome中。它不会在IE/Firefox中发生。

有什么想法发生了什么,甚至更好,如何解决这个问题?

谢谢!
丹尼尔

有帮助吗?

解决方案

您并不孤单,这是错误: code.google.com/p/chromium/issues/detail?id=43796

其他提示

Chromium团队尚未解决此问题。

我发现,通过引入ClearTimeOut和SettieMout之间的一些延迟将解决问题。

// mouse event
document.onmousemove = function(){
  clearTimeout(timeout);
  debug("Idle Timer reinitialized"); // apparently this function introduces some delay. it just works. You may want to include another timer here like for 2-3 seconds.
  timeout = setTimeout(logoutNow, systemTimeout);
}

希望能帮助到你。

您确定这是原因吗,我进行了此演示,无法复制它。

“暂停!”将在10秒后出现,在手工测试之前单击框中。

http://jsfiddle.net/pfgaj/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top