1

我需要一个关于ShowModalDialog和setTimeout的函数,所以我测试了Google Chrome中的弹出窗口 和ModalDialog,并且出现了一些问题。 有显示在页面load.one由winodw.open开了两个弹出窗口(), 另一个是由window.showmodaldialog()这样打开:两个弹出窗口被打开在chrome中使用setTimeout和showModalDialog会阻止选项卡

setTimeout(function(){window.open("PopupWindow.html","_blank","")},100); 
setTimeout(function(){window.showModalDialog("ModalDialog.html","","")},100)}; 

后,我点击PupupWindow.html上的按钮。它会调用 的功能如下:

function test() 
{ 
    setTimeout(function(){alert("test");},1000); 
} 

这是谷歌浏览器14做工精细。将Google Chrome更新到版本19, 后,在调用test()之前PopupWindow.html将挂起,直到ModalDialog.html关闭。 请告诉我为什么这个案例在Google Chrome 19上遭到破坏,或者在Google Chrome 19上以任何方式执行showModalDialog 和window.open()19.感谢您的帮助。

回答

0

浏览器的新版本实际上是表现出正确的行为。在Safari和Firefox中,我也会遇到同样的情况。

模式对话框就其本质都应该防止用户与应用程序的其余部分交互,直到他们完成了模态对话框。

Chrome浏览器已通过若干问题与不正确处理这个困扰。对于一些示例,参见http://code.google.com/p/chromium/issues/detail?id=4202,http://code.google.com/p/chromium/issues/detail?id=16045http://code.google.com/p/chromium/issues/detail?id=42939。看起来,如果你遇到不同的行为,他们可能终于开始清理其中的一部分了。

一般使用window.showModalDialog应避免一些,我在这里详细的原因 - http://tjvantoll.com/2012/05/02/showmodaldialog-what-it-is-and-why-you-should-never-use-it/

如果你需要一个模式对话框我强烈推荐jQuery UI's dialog plugin

相关问题