How can I programmatically disable IE compatibility mode?

HtmlXhtmlInternet Explorer-8Internet Explorer-7

Html Problem Overview


I have been stuck on this one for a while - I couldn't figure out why a website renders differently in two identical versions of Internet Explorer. Half an hour ago I came across a compatibility mode button in IE which made me really angry.

Disabling compatibility mode has fixed my problem.

Is there a way to disable it programmatically, i.e. from a web page?

Edit:

Just came across this blog https://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx

I'll post an example code after reading the article

Html Solutions


Solution 1 - Html

If you want the "old" rendering, and no button to show up on the toolbar so that users can switch modes you can use this:

<head>
  <!-- Mimic Internet Explorer 7 -->
  <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" >
  <title>My Web Page</title>
</head>

other options (old and new) include:IE=5, IE=7, IE=8, or IE=edge

(edge equals highest mode available)

Solution 2 - Html

You probably need to set your DOCTYPE correctly. Check out MSDN's articles on DOCTYPE and Defining Document Compatibility for more info.

Solution 3 - Html

Please also note that also IE8 browser settings can enforce a certain mode. I have a customer who has IE8 compatibility mode enforced by policy in intranet mode.

Solution 4 - Html

Please add to force IE not apply Compatibility Mode

<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">

Solution 5 - Html

In my case, I fixed it by adding the following tag after the <head> tag:

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser338195View Question on Stackoverflow
Solution 1 - HtmlscunliffeView Answer on Stackoverflow
Solution 2 - HtmlDonutView Answer on Stackoverflow
Solution 3 - HtmlDeckardView Answer on Stackoverflow
Solution 4 - HtmlThe Anh NguyenView Answer on Stackoverflow
Solution 5 - HtmlJulian MorenoView Answer on Stackoverflow