I'm detecting the browser version using jQuery and setting CSS based on the browser version.
if ( getBrowserVersion() == '8' ) {
$('head').append('<link href="/css/MSIE8.css" rel="stylesheet" id="MSIECSS8" />');
}
function getBrowserVersion() {
var ua = navigator.userAgent, tem,
M = ua.match(/(opera|chrome|safari|firefox|msie|wow64|trident(?=\/))\/?\s*(\d+)/i) || [];
if ( /trident/i.test( M[1] ) ) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE ' + ( tem[1] || '' );
}
}
This works when I emulate IE8 in IE11 using F12-developer tools. But it doesn't pick the CSS when I run the website directly on IE8. Any idea on how to make this work? Appreciate your help!