Javascript检查兼容性视图是否已启用

时间:2011-04-07 12:27:55

标签: javascript internet-explorer

如何使用Javascript检查兼容性视图是否已启用?

无论哪个版本的IE都无关紧要,我只需要知道兼容性视图是否已打开。

2 个答案:

答案 0 :(得分:1)

Determining Document Compatibility Mode

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.
    }

答案 1 :(得分:0)

不久前偶然发现了这篇博客文章。也许这就是你要找的东西:http://blog.strictly-software.com/2009/03/detecting-ie-8-compatibility-modes-with.html