防止js alert()暂停计时器 [英] Prevent js alert() from pausing timers
本文介绍了防止js alert()暂停计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我安排了一些计时器进行测验.事情是,我刚意识到我放
So I made some timers for a quiz. The thing is, I just realized when I put
javascript: alert("blah");
在地址中,弹出警报框暂停我的计时器.在测验中这是非常不需要的.
in the address, the popup alert box pauses my timer. Which is very unwanted in a quiz.
我认为没有任何方法可以阻止这种行为...但是我还是要问.
I don't think there is any way to stop this behaviour... but I'll ask anyway.
如果没有,建议我该怎么办?
If there is not, mind suggesting what should I do?
推荐答案
显然,预览渲染与发布的渲染不同.该段是为了确保接下来的两行显示为代码.
Apparently the preview rendering differs from the posted rendering. This paragraph is here to make sure the next two lines show up as code.
// Preserve native alert() if you need it for something special
window.nativeAlert = window.alert;
window.alert = function(msg) {
// Do something with msg here. I always write mine to console.log,
// but then I have rarely found a use for a real modal dialog,
// and most can be handled by the browser (like window.onbeforeunload).
};
这篇关于防止js alert()暂停计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文