setInterval停止警报工作 [英] setInterval stop working on alert

查看:85
本文介绍了setInterval停止警报工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个MCQ测验,每个问题都有一段时间.我还在脚本中使用了onbeforeunload,以防止用户意外离开测验页面.但是当显示警报时,我的setInterval计数器停止工作.即使有警报,我如何使倒数计时不停止?

I am creating a MCQs quiz and there is a time for each question. I have also used onbeforeunload in my script to prevent the user from accidentally navigating away from the quiz page. But when that alert gets display my setInterval counter stop working. How can i make the countdown to not stop even if there is an alert?

在这里进一步解释我的问题的是 FIDDLE

To further explain my problem here is the FIDDLE

推荐答案

浏览器对话框被阻止.打开它们时,所有脚本执行都会停止.您无法更改此行为.

Browser dialogs are blocking. All script execution stops when they are open. You cannot change this behaviour.

这篇关于setInterval停止警报工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆