javascript - IE8 兼容模式 - document.documentMode

标签 javascript jquery internet-explorer ie8-compatibility-mode

我需要一个 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/

相关文章:

javascript - 在 mouseup 上切换 CSS

java - 从另一个列表中选择值时从数据库加载列表

jQuery 平滑滚动不适用于 SSL URL

Ajax 更新程序无法在 Internet Explorer 中运行

Jquery UI 模态对话框在 IE6 和 IE7 中不起作用

VBA单击IE中没有ID、名称、类名的按钮

javascript - 尝试调用 jQuery 设置的 onchange 方法

javascript - 无论 promise 是否兑现,如何执行相同的操作?

java - 正则表达式查找所有带有 http url 的 img 标签

javascript - 如何让按钮漂浮在剑道小部件上