Disable compatibility mode on Internet Explorer from your web server

Published: {ts '2014-09-09 00:00:00'}
Author: Steven Neiland
Site Url: http://www.neiland.net/article/disable-compatibility-mode-on-internet-explorer-from-your-web-server/

Our main web app in work has always been designed to work for IE8 and above but on occasion we have users turning on compatibility mode on Internet Explorer by mistake. When this happens some visual elements invariable get screwed up and we have to explain to the user how to find and turn off the feature.

While it doesn't happen often I decided to come up with a solution to the problem after I had to physically walk up to a users desk to click on the broken page icon to turn it off for them. After some quick googling I discovered you can actually disable this button from the server side.

Meta Tag

The most common solution put forward and the the first one I tried is to put a "X-UA-Compatible" meta tag in the html immediately after the opening head tag.

Supposedly this tells the internet explorer which mode is best for rendering the website with the content attribute value "IE=edge" always being the most recent version. A complete listing of all the different values can be found here.

...snip ...snip

As you can probably tell this did not work at all for me.

IIS

The solution turned out not to be too different. Instead of added a meta tag to the site code I added a custom header through the web.config file like this.

Apache

You can also achieve the same results from Apache. First make sure you have the "mod_headers" and "mod_rewrite" modules installed and enabled on apache.

With these setup you just add the following line of code to your .htaccess file.

Header set X-UA-Compatible IE=Edge

In Code

You can also do this through your favorite server side language (although I have not tested these).

ColdFusion

PHP

if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) { header('X-UA-Compatible: IE=edge'); }