Force IE compatibility mode off using tags

后端 未结 12 1337
广开言路
广开言路 2020-11-22 07:56

I am doing work for a client who forces compatibility mode on all intranet sites. I was wondering if there is a tag I can put into my HTML that forces compatibility mode off

相关标签:
12条回答
  • 2020-11-22 08:19

    As suggested in this answer to a related question, "edge" mode can be set in the Web.Config file. This will make it apply to all HTML returned from the application without the need to insert it into individual pages:

    <configuration>
        <system.webServer>
            <httpProtocol>
                <customHeaders>
                    <add name="X-UA-Compatible" value="IE=edge" />
                </customHeaders>
            </httpProtocol>
        </system.webServer>
    </configuration>
    

    This same step can also be accomplished by modifying the "HTTP Response Headers" using IIS Manager for the IIS server, entire website, or specific applications.

    0 讨论(0)
  • 2020-11-22 08:23

    The meta tag solution wasn't working for us but setting it in the response header did:

    header('X-UA-Compatible: IE=edge,chrome=1');
    
    0 讨论(0)
  • 2020-11-22 08:25

    IE8 defaults to standards mode for the intERnet and quirks mode for the intRAnet. The HTML meta tag is ignored if you have the doctype set to xhtml transitional. The solution is to add an HTTP header in code. This worked for us. Now our intranet site is forcing IE8 to render the app in standards mode.

    Added to PageInit of the base page class (ASP.net C#):

    Response.AddHeader("X-UA-Compatible", "IE=EmulateIE8");
    

    reference: http://ilia.ws/archives/196-IE8-X-UA-Compatible-Rant.html

    0 讨论(0)
  • 2020-11-22 08:26

    If you have access to the server, the most reliable way of doing this is to do it on the server itself, in IIS. Go in to IIS HTTP Response Headers. Add Name: X-UA-Compatible
    Value: IE=edge This will override your browser and your code.

    0 讨论(0)
  • 2020-11-22 08:27

    I believe this will do the trick:

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    
    0 讨论(0)
  • 2020-11-22 08:31

    There is the "edge" mode.

    <html>
       <head>
          <meta http-equiv="X-UA-Compatible" content="IE=edge" />
          <title>My Web Page</title>
       </head>
       <body>
          <p>Content goes here.</p>
       </body>
    </html>
    

    From the linked MSDN page:

    Edge mode tells Windows Internet Explorer to display content in the highest mode available, which actually breaks the “lock-in” paradigm. With Internet Explorer 8, this is equivalent to IE8 mode. If a (hypothetical) future release of Internet Explorer supported a higher compatibility mode, pages set to Edge mode would appear in the highest mode supported by that version; however, those same pages would still appear in IE8 mode when viewed with Internet Explorer 8.

    However, "edge" mode is not encouraged in production use:

    It is recommended that Web developers restrict their use of Edge mode to test pages and other non-production uses because of the possible unexpected results of rendering page content in future versions of Windows Internet Explorer.

    I honestly don't entirely understand why. But according to this, the best way to go at the moment is using IE=8.

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