【问题标题】:Enterprise mode detection using JavaScript使用 JavaScript 进行企业模式检测
【发布时间】:2015-12-04 02:17:14
【问题描述】:

在 ie9 浏览器而不是文档模式 Edge 中,它正在更改为文档模式 ie8。

我知道这是因为打开了企业模式。有任何方法可以覆盖到边缘模式。

由于这种错误的渲染模式,出现了一些对齐问题,我必须修复它。

为了解决这个问题,我需要检测渲染的配置文件是否为 Enterprise 模式和 Document type id ie8

在所有其他浏览器中都没有问题。

【问题讨论】:

  • 这不适用于相同的 IE 版本,但我认为另一个类似问题的答案将适用。 stackoverflow.com/a/28821906/1132499 另外,IE=Edge 的末尾应该有双引号吗?
  • 哦,双引号是复制错误。

标签: html internet-explorer-9


【解决方案1】:

您可以尝试使用navigator.userAgent 属性的功能如下:

function getIEVersion() { if (~navigator.userAgent.search(/MSIE (\d)/g)) { return +navigator.userAgent.match(/MSIE (\d+)/)[1]; } else { return; } }.

注意!在 IE11 中你会得到undefined(因为它有另一个 UserAgent,但 IE11 不是你的情况)。

为了检查兼容模式,你可以试试这个:

function isIEInCompatibleMode() { return !!~navigator.userAgent.search(/compatible/g); }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多