Override intranet compatibility mode IE8

后端 未结 19 2090
执念已碎
执念已碎 2020-11-22 10:04

By default IE8 forces intranet websites into compatibility mode. I tried changing the meta header to IE8, but it doesn\'t acknowledge the meta header and just uses the brows

19条回答
  •  灰色年华
    2020-11-22 10:20

    Stefan S' comment about the document mode versus browser mode were very pertinent for my problem.

    I have the X-UA-Content meta data in the page, but I was client-side testing the browser version via navigator.appVersion. This test does not reflect the meta data because it is giving the browser mode not the document mode.

    The answer for me was to test the document.documentMode something like:

    function IsIE(n)
    {
        if (navigator.appVersion.indexOf("MSIE ") == -1) return false;
        var sDocMode = document.documentMode;
        return (isFinite(sDocMode) && sDocMode==n);
    }
    

    Now, my meta X-UA-Content tag reflects in my browser test.

    Why do I do such a frowned-on thing as test the browser? Speed. Various of my jQuery add-ins, like tablesorter are just too slow on IE6/7, and I want to turn them off. I am not sure that testing for browser features can help me solve this otherwise.

提交回复
热议问题