IE9 has a weird problem where it renders intranet sites in compatibility mode.
Does anyone know a way how to prevent this from happening?
Note: I am not looking for a way to prevent it on a single users machine, but some programmatic way to prevent the site from ever rendering in compatibility mode.
If you can add code to the homepage, you can simply add this:
to your website's header.
(You can also use
<meta http-equiv="X-UA-Compatible" content="IE=9">
to force IE9-Renderer) This will force IE9 to render in standard mode.Another way is to use another doctype: Put this to the top of your code:
This can be done by adding a simple meta tag
Another way to accomplish this is to add this code to your .htaccess file!
Following from @novicePrgrmr's answer, there seems to be a workaround for IE9 loading Intranets in IE7-mode. While this still triggers compatibility mode, I found a slight modification to Paul Irish's HTML5 boilerplate markup at least allows IE9 to render Intranets in IE9 standards:
This is still valid HTML, and existing IE-specific CSS should still work just fine, provided you target IE using
.lt-ie
rather thanhtml.lt-ie
.After an exhaustive search, I found out how to successfully prevent an intranet site from rendering in compatibility mode in IE9 on this blog:
From Tesmond's blog
There are 2 quirks in IE9 that can cause compatibility mode to remain in effect. The X-UA-Compatible meta element must be the first meta element in the head section. You cannot have condtional IE statements before the X-UA-Compatible meta element. This means that if you use Paul Irish's wonderful HTML5 Boilerplate then on an Intranet with default IE9 settings your website will display in compatibility mode. You need to change the start of the boilerplate from the following:-
to: