我需要一个 javascript 代码“document.documentMode”,该代码在真正的 IE8 模式下值为 8,在 IE7 模式下值为 7。
两种情况下的用户代理字符串都是相同的,并且仍然显示 IE8。 请注意,此 JavaScript 变量仅在 IE8 中可用。
基本上,我必须检测某人何时运行 IE8(周二)和 IE8(兼容模式)。
最佳答案
“基本上,我必须检测某人何时运行 IE8(周二)和 IE8(兼容模式)。”
var ie8 = /msie\s+8/i.test(navigator.userAgent);
var mod = document.documentMode;
if (ie8 && mod == 8) {
alert("found!");
}
// or
var ok = (
/msie\s+8/i.test(navigator.userAgent) &&
document.documentMode == 8
);
if (ok) {
// ...
关于javascript - IE8 兼容模式 - document.documentMode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11898559/