Internet Explorer 9 忽略带有框架集的 showModalDialog 的dialogWidth/Height
我有一个较旧的 Intranet 应用程序,需要在模式对话框窗口内显示两个框架(固定菜单栏和可变内容数据视图)。目前,使用 window.showModalDialog
函数打开对话框,只要我在 Internet Explorer 8(使用任何视图模式)或 Internet Explorer 9 中打开页面,一切都会正常工作兼容性视图已启用。
不幸的是,当关闭 IE9 中的兼容性视图时,无论指定的dialogWidth 和dialogHeight 值如何,对话框窗口始终以266 x 138 像素的大小打开。我创建了一个显示问题的小示例:
index.html(最初加载的页面):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<input type="button" value="popup"
onclick="showModalDialog ('dialog.html', null, 'dialogWidth:500px;dialogHeight:400px;resizable:yes')" />
</body>
</html>
dialog.html(在对话框窗口内打开的页面):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html>
<frameset rows="*, 70">
<frame src="frame1.html" />
<frame src="frame2.html" />
</frameset>
</html>
frame1.html/frame2.html(两个框架的内容):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<p>Frame Content</p>
</body>
</html>
仅问题如果我在对话框中显示框架集文档,则会发生这种情况。当打开常规 html 文档(包含带有某些内容的正文)时,大小将按照函数调用中指定的方式设置。
另外,在文档加载后更改对话框大小仅适用于常规文档,不适用于框架集,请在 dialog.html 中的开始 html 标记后插入以下代码:
<head>
<script type="text/javascript" />
window.setTimeout (function () { window.dialogWidth = "500px"; window.dialogHeight = "400px"; }, 10000);
</script>
</head>
因为我不想更改应用程序的整体结构(尤其是基于框架的结构),我不知道我是否做错了什么,或者我是否在 Internet Explorer 中发现了错误,欢迎任何解决此问题的提示。
I've got an older intranet application that needs to show two frames (a fixed menu bar and a variable content data view) inside a modal dialog window. At the moment the dialog is opened using the window.showModalDialog
function and everything works fine, as long as I'm opening the page in Internet Explorer 8 (with any view mode) or in Internet Explorer 9 with Compatibility View enabled.
Unfortunately, when switching off the Compatibility View in IE9, the dialog window always opens in a size of 266 x 138 pixels, regardless of the specified dialogWidth and dialogHeight values. I created a small example showing the problem:
index.html (the page initially loaded):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<input type="button" value="popup"
onclick="showModalDialog ('dialog.html', null, 'dialogWidth:500px;dialogHeight:400px;resizable:yes')" />
</body>
</html>
dialog.html (the page opened inside the dialog window):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html>
<frameset rows="*, 70">
<frame src="frame1.html" />
<frame src="frame2.html" />
</frameset>
</html>
frame1.html/frame2.html (the content of both frames):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<p>Frame Content</p>
</body>
</html>
The problem only occurs if I'm showing a frameset document inside the dialog. When opening a regular html document (containing a body with some content), the size is set as specified in the function call.
Also, changing the dialog size after the document has loaded only works for regular documents, not for framesets, f.e. insert the following code after the opening html tag in dialog.html:
<head>
<script type="text/javascript" />
window.setTimeout (function () { window.dialogWidth = "500px"; window.dialogHeight = "400px"; }, 10000);
</script>
</head>
As I don't want to change the overall structure of the application (especially the frame-basedness) and I don't know if I'm doing something wrong or if I've found a bug in Internet Explorer, any hints for resolving this problem are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我也遇到了同样的问题,最后通过将元标记兼容性更改为 ie8 对我有用。
删除模型对话框中的所有这些文档类型,然后添加元标记,例如
“≮meta http-equiv =“X-UA-Compatible”content =“IE = EmulateIE8 ≯”
我希望这会有所帮助。
The same issue I also faced, finally it worked for me by change the meta tag compatibility to ie8.
Remove all those doctype's in model dialog and just add the meta tag like
"≮ meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8 ≯"
i hope this will help.
我还在 Internet Explorer Web 开发论坛并能够获得我想在这里分享的解决方案:
根据 Microsoft Connect,测试能够验证此问题是
已在 Windows 8 Developer 上的 Internet Explorer 10 中解决。。
对于 IE9,可以通过删除 dialog.html 中的 doctype 声明来绕过该问题。这会强制此特定页面进入 Quirks 模式,但随后对话框会再次以正确的大小显示。
I also discussed the issue on the Internet Explorer Web Development Forum and was able to get a solution that I want to share here:
According to Microsoft Connect, Testing was able to verify that this issue was
resolved in Internet Explorer 10 on Windows 8 Developer.
For IE9 the problem could be bypassed by removing the doctype declaration inside dialog.html. This forces this particular page into Quirks mode but then the dialog is shown in the right size again.
将此代码添加到dialog.html
Add this code to dialog.html