76

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • See http://stackoverflow.com/questions/1014666/force-ie8-into-ie7-compatiblity-mode. It has nothing to do with the doctype. – David Kolar Sep 27 '10 at 12:53
  • I expect there is a windows/IE setting, but nothing you can do from the webpage to dictate this, since you want to stay in IE8, not go to compatability mode. – James Black Sep 27 '10 at 12:55
  • Not sure if you can do that through a web page, may be better to code for IE compatibility mode (IE 7). :( – Spooks Sep 27 '10 at 12:50

5 Answers5

93

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)

scunliffe
  • 62,582
  • 25
  • 126
  • 161
  • Thank you - this works. This still means that I have to change my code to work in IE 7.. –  Sep 27 '10 at 13:03
  • Is there something in particular you have that won't work in IE8 Standards mode? If so, post another question and maybe we can solve it for you. – scunliffe Sep 27 '10 at 13:34
  • It's a positioning of divs. I have read somewhere that IE7 needs extra few pixels for left and right margins or something on those lines. THe site looks great in firefox, safari, chrome, even ie 8 without compatibility mode...but IE 7 is a different story –  Sep 27 '10 at 14:35
  • Hey, vikp. I've never had problems between IE7 and IE8 as long as the DOCTYPE was specified and its (the DOCTYPE's) standards were met. – Francisc Sep 28 '10 at 01:19
  • I think @Francisc and Donut (other answer) are right, You'll need a doctype as well. – Tim Büthe May 11 '12 at 09:38
  • 1
    Omg thank you. This drove me nuts. I am a web developer and develop stuff on IE9 platform but when I submit the work and it gets pushed through other things, it ends up all distored on a live side. This little trick allowed me to force IE9 settings, just the way I see them, getting rid of countless seemingly CSS issues which interfered wtith even jQuery operations. – Lukas Jun 18 '12 at 16:19
  • 2
    If for some reason you can't place this in the head before script or css, you can add it as a header in your web server configuration. – Lucas Holt Jan 28 '13 at 20:36
  • Thanks @LucasHolt, putting it in the header is the way to go. I just added this to the top of my top-level servlet filter (java solution): `((HttpServletResponse)response).setHeader("X-UA-Compatible", "IE=edge");` – JMB Dec 11 '13 at 00:35
7

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

Donut
  • 110,061
  • 20
  • 134
  • 146
4

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.

Deckard
  • 2,384
  • 1
  • 19
  • 35
  • +1, this can be enforced in IE9 aswell. Probably in all newer IE versions I guess. – am_ Oct 11 '13 at 11:09
0

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">
The Anh Nguyen
  • 748
  • 2
  • 11
  • 27
0

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

<meta content="IE=edge" http-equiv="X-UA-Compatible">
Julian Moreno
  • 1,084
  • 3
  • 15
  • 30