Can I differentiate if client\'s browser is IE7 or e.g. IE9 in IE7 compatibility mode? I\'m trying to figure out if I can do a JS check on my site which would recognize two
This works for me:
/**
* Actual IE8-Browser running in IE8-Compat-Mode or IE7 Mode?
*/
MyUtils.isIE8CompatMode= function(){
if($.browser.msie && navigator.userAgent.indexOf('MSIE 7.0')>=0){
return true;
}
return false;
}
An actual IE8 browser has 3 Document-Modes (IE7, IE8 & Quirks) and 3-Browser-Modes (IE7, IE8 and IE8-Compatibility). We can enforce the Document-Mode to be IE8 with:
But, we cannot enforce the Browser-Mode, which is determined by Browser-configuration. For example: some of our customers have the "render all pages in compatibility-mode"-checkbox checked in their Compatibility-View-Settings-Dialog. If that is the case, we can do nothing about it.
See the very enlightening diagram on this site:
-> How ie8 determines compatibility-mode
What do we use the above function for? Since our Page shows some glitches when in compatibility-mode we need to tell the user, why it is looking bad and what he can do about it. So we use the above function to tell if we are in trouble and then render a small warning to the user.
In ie9 and ie10 compatiblity-modes our app looks fine, so we dont need it there. This response may be considered an answer to this question: detect ie8 compatibility mode which was marked as a duplicate of this one. Perhaps it helps someone.