How to disable Compatibility View in IE

前端 未结 8 1959
独厮守ぢ
独厮守ぢ 2020-12-04 07:24

I am wondering how do you stop people who are using IE 8 from going to Compatibility mode?



        
相关标签:
8条回答
  • 2020-12-04 08:04

    Another way to achieve this in Apache is by putting the following lines in .htaccess in the root folder of your website (or in Apache's config files).

    BrowserMatch "MSIE" isIE
    BrowserMatch "Trident" isIE
    Header set X-UA-Compatible "IE=edge" env=isIE
    

    This requires that you have the mod_headers and mod_setenvif modules enabled.

    The extra HTTP header only gets sent to IE browsers, and none of the others.

    0 讨论(0)
  • 2020-12-04 08:08

    This should be enough to force an IE user to drop compatibility mode in any IE version:

    <meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
    

    However, there are a couple of caveats one should be aware of:

    • The meta tag above should be included as the very first tag under <head>. Only the <title> tag may be placed above it.

    If you don't do that, you'll get an error on IE9 Dev Tools: X-UA-Compatible META tag ignored because document mode is already finalized.

    • If you want this markup to validate, make sure you remember to close the meta tag with a /> instead of just >.

    • Starting with IE11, edge mode is the preferred document mode. To support/enable that, use the HTML5 document type declaration <!doctype html>.

    • If you need to support webfonts on IE7, make sure you use <!DOCTYPE html>. I've tested it and found that rendering webfonts on IE7 got pretty unreliable when using <!doctype html>.

    The use of Google Chrome Frame is popular, but unfortunately it's going to be dropped sometime this month, Jan. 2014.

    <meta http-equiv="X-UA-Compatible" content="IE=EDGE,chrome=1">
    

    Extensive related info here. The tip on using it as the first meta tag is on a previously mentioned source here, which has been updated.

    0 讨论(0)
提交回复
热议问题