我有一個較舊的Intranet應用程序,需要在模式對話框窗口中顯示兩個框架(一個固定菜單欄和一個可變內容數據視圖)。目前,使用window.showModalDialog
函數打開對話框並且一切正常,只要我在Internet Explorer 8(使用任何視圖模式)或Internet Explorer 9中打開頁面,並且兼容性視圖已啓用。Internet Explorer 9忽略了使用框架集showModalDialog的dialogWidth/Height
不幸的是,在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文檔(包含一些內容的主體)時,大小按照函數調用中的指定進行設置。
此外,文檔加載後更改對話框大小僅適用於常規文檔,而不適用於框架集f.e.插入打開HTML標記後,將下面的代碼dialog.html:
<head>
<script type="text/javascript" />
window.setTimeout (function() { window.dialogWidth = "500px"; window.dialogHeight = "400px"; }, 10000);
</script>
</head>
因爲我不想改變應用程序(尤其是框架basedness)的整體結構,我不知道如果我做錯了某些事情,或者如果我在Internet Explorer中發現了一個錯誤,則歡迎提供解決此問題的任何提示。
此問題最近出現在IE11上。我的對話框沒有文檔類型,所以我無法使用D.Calliess的解決方案。您的解決方案適用於IE11! – Keorl 2015-08-14 13:35:14