Is there anyway to determine if the browser is running in compatibility mode via the userAgent string?

Gold Contributor
Gold Contributor
 
3 REPLIES 3

Is there anyway to determine if the browser is running in compatibility mode via the userAgent string?

Tealium Employee
Hi Joe, I'm assuming you are asking about IE8? Based on http://stackoverflow.com/questions/1328963/detect-ie8-compatibility-mode there are two ways. 1) IE8 includes a trident token in the User-Agent string regardless of compatibility mode. See MSDN for more details: http://blogs.msdn.com/ie/archive/2009/01/09/the-internet-explorer-8-user-agent-string-updated-editio... IE7 on Windows Vista Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0) IE8 on Windows Vista (Compatibility View) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/4.0) IE8 on Windows Vista Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0) 2) You can also check the value of document.documentMode which will have a value of 8 if true IE8 mode and 7 in IE7 mode. The user agent string will be identical in both cases and will still state IE8. Note that this JavaScript variable is only available in IE8. Hopefully that is what you are looking for. I'm guessing you are wanting to add a load rule that suppresses a tag based on compatibility mode. If this is the case you'll need to add some logic to a JavaScript extension scoped to Pre-Loader that outputs a global JS variable and then reference that variable in the load rules. Please let me know if this helps.

Is there anyway to determine if the browser is running in compatibility mode via the userAgent string?

Gold Contributor
Gold Contributor
I am looking to determine IE8, 9, 10 & 11. I am trying to target these users with a jquery dialog box to alert them of site performance issues.

Is there anyway to determine if the browser is running in compatibility mode via the userAgent string?

Tealium Employee
Gotcha. I just did a search for "js detect ie compatibility mode" and found this post to github https://gist.github.com/jasongaylord/5733469. I think this is up the alley of what you are looking for. It's checking to ensure jQuery is installed, captures the browser and if compatibility mode is on, and displays some text.
Public