I want to bounce users of our web site to an error page if they\'re using a version of Internet Explorer
prior to v9. It\'s just not worth our time and money to
Detecting IE and its versions couldn't be easier, and all you need is a bit of native/vanilla Javascript:
var uA = navigator.userAgent;
var browser = null;
var ieVersion = null;
if (uA.indexOf('MSIE 6') >= 0) {
browser = 'IE';
ieVersion = 6;
}
if (uA.indexOf('MSIE 7') >= 0) {
browser = 'IE';
ieVersion = 7;
}
if (document.documentMode) { // as of IE8
browser = 'IE';
ieVersion = document.documentMode;
}
And this is a way to use it:
if (browser == 'IE' && ieVersion <= 9)
document.documentElement.className += ' ie9-';
.
Works in all IE versions, including higher versions in lower Compatability View/Mode, and documentMode
is IE proprietary.