How to prevent IE9 from rendering intranet sites in compatibility mode

novicePrgrmr picture novicePrgrmr · Oct 15, 2012 · Viewed 16.3k times · Source

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.

Answer

novicePrgrmr picture novicePrgrmr · Oct 16, 2012

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:-

<!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 charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

to:

<!doctype html>
<html class="no-js" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">