0
因爲我的jsp和css有一個問題,它不受IE兼容視圖支持,但它在IE標準視圖和所有其他瀏覽器所以我想設計我的代碼,適用於任何模式的任何瀏覽器,請提供一個解決此問題的建議是否有可能在IE標準視圖中顯示jsp頁面,但不能在兼容視圖中顯示
因爲我的jsp和css有一個問題,它不受IE兼容視圖支持,但它在IE標準視圖和所有其他瀏覽器所以我想設計我的代碼,適用於任何模式的任何瀏覽器,請提供一個解決此問題的建議是否有可能在IE標準視圖中顯示jsp頁面,但不能在兼容視圖中顯示
您必須測試只存在於IE8或更高版本中的document.documentMode值。如果在IE8標準模式下顯示頁面,則引擎值爲8,但如果頁面以IE7兼容模式(在IE8瀏覽器上)顯示,則值將爲7.
此代碼片段是從Microsoft MSDN中提取的,並且我認爲這是自我解釋。
engine = null;
if (window.navigator.appName == "Microsoft Internet Explorer")
{
// This is an IE browser. What mode is the engine in?
if (document.documentMode) // IE8 or later
engine = document.documentMode;
else // IE 5-7
{
engine = 5; // Assume quirks mode unless proven otherwise
if (document.compatMode)
{
if (document.compatMode == "CSS1Compat")
engine = 7; // standards mode
}
// There is no test for IE6 standards mode because that mode
// was replaced by IE7 standards mode; there is no emulation.
}
// the engine variable now contains the document compatibility mode.
}
但是,您需要知道以前至尊版本的IE瀏覽器正在顯示頁面。所以如果它是8並且返回的值是7,那麼以兼容模式顯示。