是否可以在 IE 标准视图中显示 jsp 页面,但不能在兼容视图中显示
Is it possible to display a jsp page in IE standard view but not in compatible view
因为我的 jsp 和 css 有问题,IE 兼容视图不支持,但它在 IE 标准视图和所有其他浏览器中工作正常,所以我想设计我的代码适用于任何模式下的任何浏览器,请提出克服此问题的建议
您必须测试 document.documentMode 值,该值仅存在于 IE8 或更高版本中。如果页面以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,则以兼容模式显示。
因为我的 jsp 和 css 有问题,IE 兼容视图不支持,但它在 IE 标准视图和所有其他浏览器中工作正常,所以我想设计我的代码适用于任何模式下的任何浏览器,请提出克服此问题的建议
您必须测试 document.documentMode 值,该值仅存在于 IE8 或更高版本中。如果页面以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,则以兼容模式显示。