I can find out the browser version and specific capabilities using the HttpBrowserCapabilities object, but is there a way I can find the Document Mode that the browser is using to render?
The equivalent of the JavaScript property document.documentMode
The mode can be changed via the developer tools
Update
I was hoping to include a separate stylesheet for IE7 and below using something like this in my razor layout page...
@if (ViewContext.IsBrowserOlderThanIE8()) {
<link href="Ie7.css" rel="stylesheet" type="text/css" />
}
Within function IsBrowserOlderThanIE8
I can detect the browser version, but this is not enough to know what document mode the client is using. The document mode has more baring on the actual rendering engine used.
You can determine it on the client side, then have the client request the correct css file...
<head>
<script type="text/javascript>"
...
var choice;
if (condition) {
choice = 'ie7';
} else {
choice = 'default';
}
document.writeln('<link type="text/css" rel="stylesheet" href="' + choice + '.css" />');
</script>
...
</head>
And of course you could make that little "selector" script a file that's included, rather than actually coding it in-line in each page you make.