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?

Palec
  • 10,298
  • 7
  • 52
  • 116
sanpall
  • 2,051
  • 2
  • 13
  • 4
  • 1
    Try http://stackoverflow.com/questions/2742853/force-internet-explorer-8-browser-mode-in-intranet/2745477#2745477, which worked for me. – David Kolar Apr 30 '10 at 15:09
  • 2
    Add this inside your pages head tag: (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: http://blogs.msdn.com/b/mikeormond/archive/2008/09/25/ie-8-compatibility-meta-tags-http-headers-user-agent-strings-etc-etc.aspx – n00b Dec 12 '12 at 00:13
  • @n00b - this has no effect on my site. – Pete Aug 06 '14 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 '15 at 00:22

19 Answers19

224

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')
Blexy
  • 9,197
  • 5
  • 35
  • 51
Andras Csehi
  • 4,309
  • 1
  • 25
  • 36
  • 20
    This is the correct answer. The meta tag has does nothing, but adding the response header works. More info here: http://social.msdn.microsoft.com/Forums/is/iewebdevelopment/thread/acf1e236-715b-4feb-8132-f88e8b6652c5#36404ffe-626f-4cf2-9f92-9e0e068cc3fc – russau Aug 18 '11 at 06:01
  • 3
    Agree. This should be the correct answer as it correctly overrides the intranet setting for this website only. – enriquein Sep 01 '11 at 18:03
  • 9
    (to clarify: It works for the document mode, but not browser mode) – codeulike Oct 20 '11 at 17:50
  • 2
    @codeulike : that won't work on IIS6 as it don't do xml configuration, but setting a global response header would. – Wyatt Barnett Oct 25 '11 at 21:06
  • 2
    @codeulike, IIS6 (or IIS7 not in integrated mode) won't use the system.webserver settings. – ScottE Mar 21 '12 at 13:22
  • 1
    @stefan.s the meta tag works when the site is not viewed as an Intranet site. – Tim B James Feb 01 '13 at 11:15
  • 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. – DeveloperChris Apr 04 '13 at 00:33
  • @TimBJames, I think that's the way it *used* to work, but I think it now works even in intranet sites. – Sam Jun 01 '13 at 00:35
  • I tried the setting in IIS7.5, but my IE8 still works in Compat Mode. – hardywang Jun 14 '13 at 18:04
  • @stefan.s I'm having some weird results from testing here: from the same web site, IE10 is ignoring the web.config entry & respecting the meta tag whilst IE8 respects the web.config entry. Both browsers have "Display intranet sites in Compatibility View" turned off? – GFoley83 Jul 02 '13 at 22:21
  • @TimBJames I am using the meta tag and I have the setting "Display Intranet Sites in compatibility view" turned on. The document mode is IE10 standards. – stefan.s Jul 03 '13 at 06:43
  • @GFoley83 Is the meta tag the first tag? Are you comparing Document Mode or Browser Mode? – stefan.s Jul 03 '13 at 06:43
  • @stefan.s does you're network pick up the site as being a Intranet site? – Tim B James Jul 03 '13 at 11:10
  • @TimBJames I think so, because the browser mode is "IE10 Compat View" in the office and IE10 from home. – stefan.s Jul 03 '13 at 13:04
  • @stefan.s ahh ok. The Meta stuff didn't work for a project of mine, so had to go down the web.config route. – Tim B James Jul 03 '13 at 13:14
  • It appears that, at least how my organisation appears to have configured our IE policies, IE will honour the "document mode" but not the "browser mode" even when it receives the header to do so. – Lachlan McD. Oct 25 '13 at 02:04
  • 4
    This is not the correct answer,as it is .net specific (without even acknowledging the fact). – Daddy32 Dec 04 '13 at 16:28
  • 1
    Yeah, this is .NET specific, but adding similar headers in the browser is relatively straightforward. I'll add it to the question. – mikl Dec 15 '14 at 22:26
  • mikl, thank you! One of the most valuable edits I've seen :) – Johnathan Elmore Apr 14 '15 at 01:18
  • 2
    This SHOULD work, and used to work, but for me, in IE10, adding the response header does not override the idiotic "Display intranet sites in Compatibility View" setting. – Sam Watkins Dec 03 '15 at 03:39
  • http://teelahti.fi/blog/disable-internet-explorer-compatibility-view-via-web-config This is a very helpful (and old) tip that solved my Internal server Compatibility problem. I tried all of your solutions before that. – GeorgiG Aug 18 '16 at 10:30
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.

Community
  • 1
  • 1
Andrew
  • 1,169
  • 8
  • 14
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.

PilotBob
  • 3,017
  • 7
  • 30
  • 46
  • 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 03 '10 at 01: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. – Andrew Lewis Jun 14 '10 at 19:17
  • 2
    I believe he did answer it from a programmer perspective. "...IE will use the mode base on the DOCTYPE". See: http://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 '10 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 '13 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 '13 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.)

stefan.s
  • 3,449
  • 2
  • 28
  • 44
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

Ala' Alnajjar
  • 770
  • 1
  • 10
  • 23
  • 11
    This is actually correct, but it MUST appear before any and all META tags on the page or it will not work. – Michael Irigoyen Aug 29 '11 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 '11 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 '11 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

James Lawruk
  • 26,651
  • 19
  • 117
  • 128
  • 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 07 '14 at 09: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
    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, ....) – Stijn de Witt Jun 21 '13 at 12:13
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.

PeteS_UK
  • 41
  • 2
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).

Gabe
  • 31
  • 1
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.

Caimen
  • 2,578
  • 2
  • 22
  • 43
  • 1
    I like your idea. but we have no firefox here. – Dennis C Jun 24 '10 at 06:47
  • The browser wars continue! :) – Nate Zaugg Jun 24 '10 at 18:27
  • 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 07 '12 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 07 '12 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 07 '12 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 07 '12 at 19:06
  • 1
    @mhenry1384 In general it is not that hard, but there are some elements such as webworkers which are only supported in certain browsers. Although in terms of cost saving a single browser intranet may outweigh the effort to get all the floats, transparent images, gradients and animations etc to behave in IE6/IE7. This would reduce testing costs by up to 80%, coding cost by 10-60%, these are not insignificant. – Andrew Mar 11 '13 at 17:11
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).

JackSparrow
  • 1,211
  • 1
  • 9
  • 14
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 {
}

}
maple_shaft
  • 10,328
  • 4
  • 42
  • 70
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 }
n00b
  • 3,335
  • 3
  • 28
  • 54
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.

Elrond_EGLDer
  • 47,430
  • 25
  • 189
  • 180
Herc
  • 487
  • 4
  • 9
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.

Schrodo_Baggins
  • 170
  • 1
  • 7
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

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

ashtonium
  • 1,788
  • 1
  • 12
  • 18
0

Had the same problem. It worked by using

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
j0k
  • 21,914
  • 28
  • 75
  • 84
Sandro
  • 1
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;
}
Community
  • 1
  • 1
mhenry1384
  • 7,126
  • 4
  • 50
  • 69