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:

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.

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';