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
I made a convenient underscore mixin for this.
_.isIE(); // Any version of IE?
_.isIE(9); // IE 9?
_.isIE([7,8,9]); // IE 7, 8 or 9?
_.mixin({
isIE: function(mixed) {
if (_.isUndefined(mixed)) {
mixed = [7, 8, 9, 10, 11];
} else if (_.isNumber(mixed)) {
mixed = [mixed];
}
for (var j = 0; j < mixed.length; j++) {
var re;
switch (mixed[j]) {
case 11:
re = /Trident.*rv\:11\./g;
break;
case 10:
re = /MSIE\s10\./g;
break;
case 9:
re = /MSIE\s9\./g;
break;
case 8:
re = /MSIE\s8\./g;
break;
case 7:
re = /MSIE\s7\./g;
break;
}
if (!!window.navigator.userAgent.match(re)) {
return true;
}
}
return false;
}
});
console.log(_.isIE());
console.log(_.isIE([7, 8, 9]));
console.log(_.isIE(11));