2012-01-30 54 views
0

我有一個較舊的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中發現了一個錯誤,則歡迎提供解決此問題的任何提示。

回答

1

我還就Internet Explorer Web Development Forum的問題,並能得到我想要分享這裏的解決方案:

據微軟連接,測試中得以驗證,這個問題就解決了Internet Explorer中 10在Windows 8 Developer上。

對於IE9,可以通過刪除dialog.html中的doctype聲明來繞開問題。這會強制這個特定的頁面進入怪異模式,但隨後對話框會再次以正確的大小顯示。

2

我也遇到了同樣的問題,最後它通過將元標記兼容性更改爲ie8來工作。

刪除模型對話框中所有的doctype的,只是添加了元標記,

「≮元HTTP的當量=」 X-UA兼容」內容= 「IE = EmulateIE8 ≯」

我希望這將有所幫助。

+0

此問題最近出現在IE11上。我的對話框沒有文檔類型,所以我無法使用D.Calliess的解決方案。您的解決方案適用於IE11! – Keorl 2015-08-14 13:35:14

0

將此代碼添加到對話框。html

<head> 
    <script> 
    (function() { 
     var _b = document.createElement('body'); 
     var _doc = document.documentElement; 
     _doc.insertBefore(_b, _doc.firstChild); 
     _doc.removeChild(_b); 
    })(); 
    </script> 
</head>