Override intranet compatibility mode IE8
Asked Answered
W

19

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?

Weldon answered 25/3, 2010 at 18:17 Comment(4)
Try #2743353, which worked for me.Harvin
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/…Jumbuck
@Jumbuck - this has no effect on my site.Inhume
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.Hydrozoan
S
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')
Segregate answered 4/5, 2011 at 17:39 Comment(21)
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/…Vibrant
Agree. This should be the correct answer as it correctly overrides the intranet setting for this website only.Chief
(to clarify: It works for the document mode, but not browser mode)Pander
@Pander : that won't work on IIS6 as it don't do xml configuration, but setting a global response header would.Supersensual
@codeulike, IIS6 (or IIS7 not in integrated mode) won't use the system.webserver settings.Ebsen
@stefan.s the meta tag works when the site is not viewed as an Intranet site.Helaina
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.Thoughtful
@TimBJames, I think that's the way it used to work, but I think it now works even in intranet sites.Teddy
I tried the setting in IIS7.5, but my IE8 still works in Compat Mode.Pentylenetetrazol
@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?Skyrocket
@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.Maddy
@Skyrocket Is the meta tag the first tag? Are you comparing Document Mode or Browser Mode?Maddy
@Maddy does you're network pick up the site as being a Intranet site?Helaina
@TimBJames I think so, because the browser mode is "IE10 Compat View" in the office and IE10 from home.Maddy
@Maddy ahh ok. The Meta stuff didn't work for a project of mine, so had to go down the web.config route.Helaina
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.Robin
This is not the correct answer,as it is .net specific (without even acknowledging the fact).Espadrille
Yeah, this is .NET specific, but adding similar headers in the browser is relatively straightforward. I'll add it to the question.Sonics
mikl, thank you! One of the most valuable edits I've seen :)Waldo
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.Essene
teelahti.fi/blog/… This is a very helpful (and old) tip that solved my Internal server Compatibility problem. I tried all of your solutions before that.Walachia
K
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.

Kremenchug answered 7/10, 2011 at 9:1 Comment(1)
This did not solve the problem for me. However, FYI, adding the "X-UA-Compatible" as a Header DID fix the problem!Cyr
P
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.

Protege answered 16/4, 2010 at 20:32 Comment(5)
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.Exeat
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.Omdurman
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!Bamby
@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.Protege
@Protege if you have 120K+ users and hundreds (if no thousands) of intranet sites to support, this is not a viable solution.Associative
M
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.)

Maddy answered 9/11, 2012 at 10:1 Comment(4)
how to change The browser mode?Muncey
the browser mode sentence is confusingChavira
@JusticeFist Yes, you are right, thanks. I tried to improve it.Maddy
@VishnudevK The only way I know is using the developer tools. But you probably want a programmatic solution.Maddy
G
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

Glycine answered 24/6, 2010 at 13:35 Comment(3)
This is actually correct, but it MUST appear before any and all META tags on the page or it will not work.Dey
This does not work for me. As far as I can tell IE8s "Display intranet sites in compatibility mode" is un-overrideablePander
(to clarify: It works for the document mode, but not browser mode. So rendering is fixed, but browser still pretends to be IE7)Pander
V
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

Votyak answered 20/4, 2012 at 13:42 Comment(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.Hernandes
H
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");
Holdall answered 31/7, 2012 at 12:53 Comment(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, ....)Bookkeeping
H
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).

Hancock answered 22/7, 2011 at 22:35 Comment(0)
J
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.

Jorrie answered 10/5, 2013 at 13:42 Comment(0)
B
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.

Broadus answered 23/6, 2010 at 21:36 Comment(7)
I like your idea. but we have no firefox here.Lovage
The browser wars continue! :)Bamby
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.Massacre
@Massacre 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.Broadus
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.Massacre
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... :-) ]Massacre
@Massacre 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.Kremenchug
R
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 {
}

}
Radome answered 14/12, 2011 at 16:56 Comment(0)
E
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).

Estrogen answered 28/6, 2012 at 6:45 Comment(0)
V
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

Valvate answered 7/9, 2010 at 14:40 Comment(0)
M
0

Had the same problem. It worked by using

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />
Mcculloch answered 16/8, 2011 at 14:49 Comment(0)
M
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://mcmap.net/q/47132/-force-quot-internet-explorer-8-quot-browser-mode-in-intranet. 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;
}
Massacre answered 7/3, 2012 at 18:0 Comment(0)
J
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 }
Jumbuck answered 12/12, 2012 at 0:20 Comment(0)
B
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.

Billhead answered 22/2, 2013 at 14:23 Comment(0)
D
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.

Dove answered 19/4, 2013 at 13:54 Comment(1)
To go to Local Group Policy Editor, you can run gpedit.msc from Run.Prescribe
E
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

Existent answered 3/7, 2014 at 19:28 Comment(1)
Not everyone is using ApacheAdon

© 2022 - 2024 — McMap. All rights reserved.