我的理解是,当打开警报对话框时,Javascript计时器会暂停。我在Chrome,Safari和IE中看到了这种行为。但是,在Firefox中,似乎定时器没有暂停。相反,它们会继续倒计时,然后当您退出alert()对话框时,该功能会立即执行。
这是Firefox中的预期行为吗?当有用户干预时,是否有ECMA标准来处理定时器?最重要的是,有没有办法在浏览器之间标准化?
示例JSFiddle尝试在不同的浏览器中运行: http://jsfiddle.net/DuncanMack/p1h5769b/
setTimeout(function() {
alert("There should be a two second pause before I come up after you close the previous window");
},2000);
alert("Will I stop event timers? It appears to depend on the browser. Hang out in this window for a while and then see if the next alert dialog comes right up or if you have two wait 2 seconds");