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
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')
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 {
}
}
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 }
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).
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
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).