What does <meta http-equiv=“X-UA-Compatible” content=“IE=edge”> do?

后端 未结 12 1448
情书的邮戳
情书的邮戳 2020-11-21 06:11

What\'s the difference if one web page starts with

 
 
   
    

        
12条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-21 06:45

    The difference is that if you only specify the DOCTYPE, IE’s Compatibility View Settings take precedence. By default these settings force all intranet sites into Compatibility View regardless of DOCTYPE. There’s also a checkbox to use Compatibility View for all websites, regardless of DOCTYPE.

    IE Compatibility View Settings dialog

    X-UA-Compatible overrides the Compatibility View Settings, so the page will render in standards mode regardless of the browser settings. This forces standards mode for:

    • intranet pages
    • external web pages when the computer administrator has chosen “Display all websites in Compatibility View” as the default—think big companies, governments, universities
    • when you unintentionally end up on the Microsoft Compatibility View List
    • cases where users have manually added your website to the list in Compatibility View Settings

    DOCTYPE alone cannot do that; you will end up in one of the Compatibility View modes in these cases regardless of DOCTYPE.

    If both the meta tag and the HTTP header are specified, the meta tag takes precedence.

    This answer is based on examining the complete rules for deciding document mode in IE8, IE9, and IE10. Note that looking at the DOCTYPE is the very last fallback for deciding the document mode.

提交回复
热议问题