如果目标页面中有 Javascript 警报,MSIE v7 不会(在我手中)打开无模式对话框或触发 onLoad 事件。以下在 MSIE v7 中失败,但在 v6 中正常(如果需要,可以使用完整源代码的 zip 文件)。
希望其他人确认这一点并讨论为什么会这样。
index.htm(此处仅显示 javascript 函数)
function openDialog(n) {
if (typeof(window.showModalDialog) == 'object') { /* Ensure of browser support */
var sURL = 'modeless.htm'; /* Set the URL */
var oWin = window.showModelessDialog(sURL); /* Create new modeless window */
}
else {
alert('"showModlessDialog" not supported!');
}
}
无模式.htm
<html>
<head>
<title>Modeless dialog</title>
</head>
<body bgcolor="#ff0000" text="#ffffff" onLoad="alert('Modeless is now loaded')">
<center>
<h1>Modeless</h1>
</center>
<script type="text/javascript" language="JavaScript">
/* If the next line is included, it prevents the onLoad event occurring in MSIE v7 */
alert('This alert stops the onLoad event in MSIE v7!');
</script>
</body>
</html>