The document.compatMode can be used to check for compatibility mode and apparently works cross-browsers (verified with IE, Chrome, Firefox):
E.g., Standard mode:
<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title></title>
<script>
window.onload = function() {
var navigator = window.navigator;
info.firstChild.data =
"\n navigator.userAgent: " + navigator.userAgent +
"\n document.compatMode: " + document.compatMode;
}
</script>
</head>
<body>
<pre id="info"> </pre>
</body>
Output:
navigator.userAgent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0)
document.compatMode: CSS1Compat
Compatibility mode:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">
<head>
<title></title>
<script>
window.onload = function() {
var navigator = window.navigator;
info.firstChild.data =
"\n navigator.userAgent: " + navigator.userAgent +
"\n document.compatMode: " + document.compatMode;
}
</script>
</head>
<body>
<pre id="info"> </pre>
</body>
Output:
navigator.userAgent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0)
document.compatMode: BackCompat