200

By default IE8 forces intranet websites into compatibility mode. I tried changing the meta header to IE8, but it doesn't acknowledge the meta header and just uses the browser setting. Does anyone know how to disable this?

4
  • 1
    Try stackoverflow.com/questions/2742853/…, which worked for me. Apr 30, 2010 at 15:09
  • 2
    Add this inside your pages head tag: <meta http-equiv="X-UA-Compatible" content="IE=8" /> (targeting the IE version you want). Note, this will NOT change the fact that the browser says its in compatibility mode (called the browser mode), but the page will render in IE8 standards mode. You will then need to alter javascript to check for "trident" if your checking for IE8 or later. See: blogs.msdn.com/b/mikeormond/archive/2008/09/25/…
    – n00b
    Dec 12, 2012 at 0:13
  • @n00b - this has no effect on my site.
    – Pete
    Aug 6, 2014 at 16:34
  • My understanding is the meta tag must me immediately after the head tag. I noticed some scripts will insert into head at index 0; thus, the meta tag will no longer be after head.
    – AMissico
    Feb 19, 2015 at 0:22

19 Answers 19

223

It is possible to override the compatibility mode in intranet.

For IIS, just add the below code to the web.config. Worked for me with IE9.

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

Equivalent for Apache:

Header set X-UA-Compatible: IE=Edge

And for nginx:

add_header "X-UA-Compatible" "IE=Edge";

And for express.js:

res.set('X-UA-Compatible', 'IE=Edge')
21
  • 20
    This is the correct answer. The meta tag has does nothing, but adding the response header works. More info here: social.msdn.microsoft.com/Forums/is/iewebdevelopment/thread/…
    – russau
    Aug 18, 2011 at 6:01
  • 3
    Agree. This should be the correct answer as it correctly overrides the intranet setting for this website only.
    – enriquein
    Sep 1, 2011 at 18:03
  • 9
    (to clarify: It works for the document mode, but not browser mode)
    – codeulike
    Oct 20, 2011 at 17:50
  • 21
    This is not the correct answer. this answer changes the document mode it DOES NOT change the important "browser mode". I am still searching for a resolution to that issue. Apr 4, 2013 at 0:33
  • 4
    This is not the correct answer,as it is .net specific (without even acknowledging the fact).
    – Daddy32
    Dec 4, 2013 at 16:28
84

Michael Irigoyen is correct BUT it is a little more complicated...

if you are using the wonderful boilerplate by Paul Irish then you will have something like the following:-

<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

This will NOT work as expected and force in IE into compatibility mode in an Intranet environment if you have the "Display intranet sites in compatibility view" checked. You need to remove the conditional IE comments to prevent Intranet compatibility mode.

So the following code will work:

<!doctype html>
<html class="no-js" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

Basically if you trigger conditional IE comments before the <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> statement then you will be forced into compatibility mode in an Intranet environment if you are running IE9 with the default settings.

UPDATE — ADDITIONAL INFO: But note that there is a trick that will make the HTML5 boilplate work:

Add an emtpy, conditional comment before the DOCTYPE. And note as well, that when you do that, then you can also add conditional comments around the X-UA-Compatible directive, making the page HTML5-valid as well. So for instance:

<!--[if HTML5]><![endif]-->
<!doctype html>
<!--[if the boilerplate conditionals goes here<![endif]-->
<head>
<!--[if !HTML5]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->

A blog post that was inspired by the first part of this answer, has more detail. And by the way: As mentioned in that blog post, one can also replace the conditional comment before the DOCTYPE with a semi conditional comment with no condition: <!--[]-->. Thus, like so:

<!--[]-->
<!doctype html>
<!--[if the boilerplate conditionals goes here<![endif]-->
<head>
<!--[if !HTML5]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->

But note that the latter variant (<--[]--><!DOCTYPE html>) will, as explained e.g by this answer to another question, activate the well know problem that it — for legacy IE versions without support for the X-UA-Compatioble (read: for IE7 and IE6) — bring the browser into into quirks-mode.

1
  • This did not solve the problem for me. However, FYI, adding the "X-UA-Compatible" as a Header DID fix the problem! Oct 31, 2012 at 17:26
34

If you pull down the "Tools" menu and choose "Compatibility View Settings" On that dialog at the bottom is a setting "Display intranet sites in compatibility mode". If you uncheck this that should resolve the problem and IE will use the mode based on the DOCTYPE.

5
  • 19
    I didn't downvote, but I would guess it's because you answered from the user's perspective (what a user should do). This question is from a web developer and is asking how to fix the problem without requiring the user to do anything in particular.
    – Roy Tinker
    Jun 3, 2010 at 1:05
  • 1
    In addition, this doesn't allow for maintaining compatibility with old applications. If you uncheck that setting, your old apps may break with no way to update them. I think the asker is looking for a way to force standards mode when all other apps on their intranet require the checkbox to be checked for compatibility mode. Jun 14, 2010 at 19:17
  • 2
    I believe he did answer it from a programmer perspective. "...IE will use the mode base on the DOCTYPE". See: msdn.microsoft.com/en-us/library/ms535242%28VS.85%29.aspx If the company is running Active Directory, changes to browser settings can be propagated by the administrator. You can't do that with FireFox!
    – Nate Zaugg
    Jun 24, 2010 at 18:29
  • @AndrewLewis perhaps. But, there is the compatibility mode button in the URL bar that will set the browser to use compat mode for that specific site. Or you can add them manually in the dialog. Once again, this stuff can be done globally by IT.
    – PilotBob
    Feb 27, 2013 at 17:31
  • 2
    @PilotBob if you have 120K+ users and hundreds (if no thousands) of intranet sites to support, this is not a viable solution.
    – yorch
    Apr 17, 2013 at 16:35
19

There is a certain amount of confusion in the answers to this this question.

The top answer is currently a server-side solution which sets a flag in the http header and some comments are indicating that a solution using a meta tag just doesn't work.

I think this blog entry gives a nice overview of how to use compatibility meta information and in my experience works as described: http://blogs.msdn.com/b/cjacks/archive/2012/02/29/using-x-ua-compatible-to-create-durable-enterprise-web-applications.aspx

The main points:

  • setting the information using a meta tag and in the header both works
  • The meta tag takes precedence over the header
  • The meta tag has to be the first tag, to make sure that the browser does not determine the rendering engine before based on heuristics

One important point (and I think lots of confusion comes from this point) is that IE has two "classes" of modes:

  1. The document mode
  2. The browser mode

The document mode determines the rendering engine (how is the web page rendered).

The Browser Mode determines what User-Agent (UA) string IE sends to servers, what Document Mode IE defaults to, and how IE evaluates Conditional Comments.

More on the information on document mode vs. browser mode can be found in this article: http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx?Redirected=true

In my experience the compatibility meta data will only influence the document mode. So if you are relying on browser detection this won't help you. But if you are using feature detection this should be the way to go.

So I would recommend using the meta tag (in the html page) using this syntax:

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

Notice: give a list of browser modes you have tested for.

The blog post also advices against the use of EmulateIEX. Here a quote:

That being said, one thing I do find strange is when an application requests EmulateIE7, or EmulateIE8. These emulate modes are themselves decisions. So, instead of being specific about what you want, you’re asking for one of two things and then determining which of those two things by looking elsewhere in the code for a DOCTYPE (and then attempting to understand whether that DOCTYPE will give you standards or quirks depending on its contents – another sometimes confusing task). Rather than do that, I think it makes significantly more sense to directly specify what you want, rather than giving a response that is itself a question. If you want IE7 standards, then use IE=7, rather than IE=EmulateIE7. (Note that this doesn’t mean you shouldn’t use a DOCTYPE – you should.)

4
  • how to change The browser mode? May 15, 2014 at 8:24
  • the browser mode sentence is confusing Sep 2, 2014 at 16:12
  • @JusticeFist Yes, you are right, thanks. I tried to improve it.
    – stefan.s
    Sep 3, 2014 at 9:55
  • 1
    @VishnudevK The only way I know is using the developer tools. But you probably want a programmatic solution.
    – stefan.s
    Sep 3, 2014 at 9:56
9

Try this metatag:

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

It should force IE8 to render as IE8 Standard Mode even if "Display intranet sites in compatibility view" is checked [either for intranet or all websites],I tried it my self on IE 8.0.6

3
  • 11
    This is actually correct, but it MUST appear before any and all META tags on the page or it will not work. Aug 29, 2011 at 13:27
  • 2
    This does not work for me. As far as I can tell IE8s "Display intranet sites in compatibility mode" is un-overrideable
    – codeulike
    Oct 20, 2011 at 17:12
  • 6
    (to clarify: It works for the document mode, but not browser mode. So rendering is fixed, but browser still pretends to be IE7)
    – codeulike
    Oct 20, 2011 at 17:49
7

Our system admin resolved this issue by unchecking the box globally for our organization. Users did not even need to log off.

enter image description here

1
  • 1
    This solution works perfectly if all sites on the intranet can use the latest web standards. However, if some cannot then this method will inadvertently break those... I would approach with caution. Feb 7, 2014 at 9:44
4

I found a working answer that allow to override the checked Intranet Compatibility View. Just add in the OnInit event of your page this line (no meta or web.config customHeader need):

Response.AddHeader("X-UA-Compatible", "IE=EmulateIE8");
1
  • 1
    Development-platform-specific answer... without even specifying the platform. I'm guessing you are talking about Visual Studio .NET? As far as I can tell 'the OnInit' event does not exist (in Javascript, Java, PHP, ....) Jun 21, 2013 at 12:13
3

Try putting the following in the header:

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

Courtesy Paul Irish's HTML5 Boilerplate (but it works in XHTML Transitional, too).

3

I was able to override compatibility mode by specifying the meta tag as THE FIRST TAG in the head section, not just the first meta tag but as and only as the VERY FIRST TAG.

Thanks to @stefan.s for putting me on to it in your excellent answer. Prior to reading that I had:

THIS DID NOT WORK

<head> 
<link rel="stylesheet" type="text/css" href="/qmuat/plugins/editors/jckeditor/typography/typography.php"/>
<meta http-equiv="x-ua-compatible" content="IE=9" >

moved the link tag out of the way and it worked

THIS WORKS:

<head><meta http-equiv="x-ua-compatible" content="IE=9" >

So an IE8 client set to use compatibility renders the page as IE8 Standard mode - the content='IE=9' means use the highest standard available up to and including IE9.

2

This isn't exactly a solution but, I feel it is the best one. On our intranet sites we tell people it can only be accessed by Firefox, we don't take kindly to IE users around here. Check the user agent on the server or client side and deny them access from IE. And I'm a .NET programmer.

7
  • 1
    I like your idea. but we have no firefox here.
    – Dennis C
    Jun 24, 2010 at 6:47
  • 22
    Worst. Suggestion. Ever. That's as bad as all the intranet sites that are IE-only. Try doing a little extra work and get your stuff working on all common browsers. It's not that hard.
    – mhenry1384
    Mar 7, 2012 at 17:16
  • 2
    @mhenry1384 Care to explain why its a terrible suggestion to have a locked down intranet system? You don't have to support quarks for old browsers. You know your users will get the experience intended. It's not a public system, who cares, do you still support IE 5.5? I tell my public users to update. I shouldnt be wasting my time on backend systems anyways, it's the public that needs me. It's not like I lock it down to IE 6 and require ActiveX like some. For instance my system allows Firefox 6 and above. So if Firefox 27 comes out, it still works. Either downvote me or make an actual argument.
    – Caimen
    Mar 7, 2012 at 18:16
  • 2
    Every intranet site I've used that was locked down to a specific browser is locked down to IE. This drives me crazy, as I hate IE as much as the next guy. Forcing your users to use the browser of your choice (not theirs), even if it's anything BUT IE, seems contrary to the web, even the intranet web. It's just not typically that hard to get a website working in IE7/8/9, especially if you use libraries like jQuery. Let the users use what they want.
    – mhenry1384
    Mar 7, 2012 at 18:35
  • 2
    A site written for Firefox 10, for example, will in my experience almost always work perfectly fine on IE9 without modification. So restricting users from using IE9 means there's something else going on. It indicates you are on an idealogical mission, not someone trying to write good web software. If it was just a question of not having time to test browsers other than Firefox, do you also restrict people from using Opera? [Sorry for being so wordy. I should go back to fixing this damn IE8 problem I'm having... :-) ]
    – mhenry1384
    Mar 7, 2012 at 19:06
1

I had struggled with this issue and wanted to help provide a unique solution and insight.

Certain AJAX based frameworks will inject javascripts and stylesheets at the beginning of the <head> and doing this seems to prevent the well-established meta tag solution from working properly. In this case I found that directly injecting into the HTTP response header, much like Andras Csehi's answer will solve the problem.

For those of us using Java Servlets however, a good way to solve this is to use a ServletFilter.

public class EmulateFilter implements Filter {

@Override
public void destroy() {
}

@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1,
        FilterChain arg2) throws IOException, ServletException {
    HttpServletResponse response = ((HttpServletResponse)arg1);
    response.addHeader("X-UA-Compatible", "IE=8");
    arg2.doFilter(arg0, arg1);
}

@Override
public void init(FilterConfig arg0) throws ServletException {
}

}
1

We can resolve this problem in Spring-Apache-tomcat environment by adding one single line in RequestInterceptor method -

//before the actual handler will be executed
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler)
throws Exception {

// Some logic

// below statement ensures IE trusts the page formatting and will render it acc. to IE 8 standard.
response.addHeader("X-UA-Compatible", "IE=8"); 

return true;
}

Reference from - How to create filter and modify response header It covers how we can resolve this problem via a RequestInterceptor (Spring).

0
0

If you want your Web site to force IE 8 standards mode, then use this metatag along with a valid DOCTYPE:

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

Note the "EmulateIE8" value rather than the plain "IE8".

According to IE devs, this should, "Display Standards DOCTYPEs in IE8 Standards mode; Display Quirks DOCTYPEs in Quirks mode. Use this tag to override compatibility view on client machines and force Standards to IE8 Standards."

more info on this IE blog post: http://blogs.msdn.com/b/ie/archive/2008/08/27/introducing-compatibility-view.aspx

0

This question is a duplicate of Force "Internet Explorer 8" browser mode in intranet.

The responses there indicate that it's not possible to disable the compatibility view (on the server side) - https://stackoverflow.com/a/4130343/24267. That certainly seems to be the case, as none of the suggestions I've tried have worked. In IE8 the "Browser Mode" gets set to Internet Explorer 8 Compatibility view no matter what kind of X-UA-Compatible header you send.

I had to do some special handling for IE7 and compatibility mode, which caused the browser to render using IE8 but report it was IE7, broke my code. This is how I fixed my code (I am aware this is a horrible hack and I should be testing for features not browser versions):

isIE8 = navigator.appVersion.indexOf("MSIE") != -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) == 8;
if (!isIE8 && navigator.appVersion.indexOf("MSIE") != -1 && parseFloat(navigator.appVersion.split("MSIE")[1]) == 7 && navigator.appVersion.indexOf("Trident") != -1) {
    // Liar, this is IE8 in compatibility mode.
    isIE8 = true;
}
0

Had the same problem. It worked by using

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
0

Add this inside your pages head tag (targeting the IE version you want):

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

Note, this will NOT change the fact that the browser says its in compatibility mode (called the browser mode), but the page will render in IE8 standards mode. If its STILL not rendering how you wish, its probably because you have javascript that is erroneously checking the I.E. version. See the following blog post to determine which property you should be keying off of because even if you set the meta X-UA-Compatible tag, the user agent string will still say MSIE 7.0.

In my case, for the fix I had to add a check for IE7 Compatibility mode. I did so using a simple javascript code:

                //IE8 and later will have the word 'trident' in its user agent string.
                if (navigator.userAgent.indexOf("Trident")>-1) { //do something }
0

For anyone else reading this looking to disable this via GPO for all users, this is the setting:

Computer Configuration/Administrative Templates/Windows Components/Internet Explorer/Compatibility View/Turn on Internet Explorer Standards Mode for Local Intranet

although the web.config edit fixed it for me.

1
  • To go to Local Group Policy Editor, you can run gpedit.msc from Run. Mar 18, 2016 at 1:43
0

Change the headers in .htaccess

BrowserMatch MSIE ie
Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie

Found the solution to this problem here: https://github.com/h5bp/html5-boilerplate/issues/378

1
  • Not everyone is using Apache
    – Burjua
    Mar 10, 2017 at 9:04
0

Stefan S' comment about the document mode versus browser mode were very pertinent for my problem.

I have the X-UA-Content meta data in the page, but I was client-side testing the browser version via navigator.appVersion. This test does not reflect the meta data because it is giving the browser mode not the document mode.

The answer for me was to test the document.documentMode something like:

function IsIE(n)
{
    if (navigator.appVersion.indexOf("MSIE ") == -1) return false;
    var sDocMode = document.documentMode;
    return (isFinite(sDocMode) && sDocMode==n);
}

Now, my meta X-UA-Content tag reflects in my browser test.

Why do I do such a frowned-on thing as test the browser? Speed. Various of my jQuery add-ins, like tablesorter are just too slow on IE6/7, and I want to turn them off. I am not sure that testing for browser features can help me solve this otherwise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.