Detecting IE Compatability Mode

I need to detect if Internet Explorer is in Compatablity Mode. If it is in compatability mode we want to show a text to the user urging them to turn off compatability mode. Googling around I found quite a lot of suggestions on how to do it. There were also quite a lot of text telling me to use Feature Detection instead of Browser Detection. There were tons of information. I zoomed in on these solutions:

http://jasongaylord.com/blog/detecting-browser-features-and-ie-compatibility-mode
http://razorborg.com/post/62072662470/modernizr-ie8-x-ua-compatible-and-standards
https://gist.github.com/chrisblakley/85dcb71dc5565d4fb8ed

I soon realized that the solution that I where to provide wasn’t going to be future proof. And that is ok for now. We just need to fix the problem. Quick and dirty is ok. So I ended up using the following javascript, which works like a charm.

https://github.com/Gavin-Paolucci-Kleinow/ie-truth/

Once included in the project its usage is straight forward:

var browser = IeVersion();
//Check that browser is Internet Explorer
if (browser.IsIE)
   // Check if browser is in compatability mode
   if (browser.CompatabilityMode)
      document.getElementById('CompatibilityModeWarning').style.display = 'block';