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?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- Is TWebBrowser dependant on IE version?
- Javascript does not work in IE8
- IE dropdown z-index bug
- Multiple cookies with same name
相关文章
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:-
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:
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: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: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 theX-UA-Compatioble
(read: for IE7 and IE6) — bring the browser into into quirks-mode.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: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.
Try putting the following in the header:
Courtesy Paul Irish's HTML5 Boilerplate (but it works in XHTML Transitional, too).
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:
One important point (and I think lots of confusion comes from this point) is that IE has two "classes" of modes:
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:
Notice: give a list of browser modes you have tested for.
The blog post also advices against the use of EmulateIEX. Here a quote:
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
moved the link tag out of the way and it worked
THIS WORKS:
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.
Had the same problem. It worked by using