Monday, March 21, 2016

Compatibility mode in IE–Developer

Enable Compatibility mode in IE through code in .NET or Web.config or HTML meta tag.

We can achieve this by setting the value of the compatibility mode.

Web page can specify compatibility mode either by using META tag or by setting the HTTP header, note thatMETA tag will take precedence over http header when both are present.

Sol 1: META Tag- place the following code in head element of web page (HTML page).

<meta http-equiv="X-UA-Compatible" content="IE=8, IE=9"/> 

Sol 2: HTTP Header- We can configure our server to send a HTTP Header along with each page i.e., send X-UA-Compatibility: IE=8 HTTP header 

Add the following code snippet in web.config file:

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

Here are other options:

  • "IE=edge"
  • "IE=11"
  • "IE=EmulateIE11"
  • "IE=10"
  • "IE=EmulateIE10"
  • "IE=9"
  • "IE=EmulateIE9
  • "IE=8"
  • "IE=EmulateIE8"
  • "IE=7"
  • "IE=EmulateIE7"
  • "IE=5