IE模式对话框会干扰window.setTimeout和window.setInterval [英] IE modal dialog interfere with window.setTimeout and window.setInterval

查看:117
本文介绍了IE模式对话框会干扰window.setTimeout和window.setInterval的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Javascript代码每3秒执行一次(比如更新UI)。下面使用window.setInterval函数显示代码。在IE(无论哪个版本)浏览器中,如果我打开"帮助" - >"关于"对话框或"Toos" - >"Internet选项"对话框,则在关闭对话框之前,计时器回调
将停止被调用。 我尝试了在IE中使用相同结果的window.setTimeout函数。
$


当我打开帮助时,我在Firefox中没有这个问题 - >关于对话框而脚本正在运行。



有没有人在IE中遇到过这个问题?那么解决方法是什么?谢谢。



< script type =" text / javascript">

window.setInterval(function(){

   //做一些事情,例如

   console.log(" hello");

},3000) ;
$
< / script>

My Javascript code does something (like update UI) every 3 seconds. The code is shown below using window.setInterval function. In IE (regardless which version) browser, if I open Help->About dialog, or Toos->Internet options dialog, the timer callback stops being called until I close the dialog.  I tried window.setTimeout function with the same result in IE.

I don't have this problem in Firefox when I open Help->About dialog while the script is running.

Has anyone encounter this problem in IE? What is the workaround then? Thanks.

<script type="text/javascript">
window.setInterval(function(){
   // do something, such as
   console.log("hello");
}, 3000);
</script>

推荐答案

是的,这是预期的行为...其他浏览器的对话框是chrome框架而不是'windows'。

yes that is the expected behavior... the other browsers' dialogs are chrome frames not 'windows'.

也许解决方法是使用全屏api(IE10 / 11)或运行你的网页使用showModalDialog或showModelessDialog(仅限IE)方法的全屏模态/无模式对话框。

Perhaps a workaround is to use the fullscreen api (IE10/11) or run your web page in a fullscreen modal/modeless dialog using the showModalDialog or showModelessDialog (IE only) method.

您可以考虑将您的Web应用程序转换为Windows应用商店js应用程序,以定位无框架浏览器市场。

You may consider converting your web application to a Windows Store js app to target the frameless browser markets.

(Chromium最近放弃了对showModalDialog的支持)。

(Chromium has recently dropped support for showModalDialog).

问候。


这篇关于IE模式对话框会干扰window.setTimeout和window.setInterval的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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