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 brows
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.
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; }
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");
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.
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
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.