Skip to content

Instantly share code, notes, and snippets.

@adamculpepper
Last active August 29, 2015 14:07
Show Gist options
  • Save adamculpepper/10d3897c8e0f378a6d75 to your computer and use it in GitHub Desktop.
Save adamculpepper/10d3897c8e0f378a6d75 to your computer and use it in GitHub Desktop.
// Slightly modified version of Angular's method of checking for Internet Explorer (IE), including checking for IE11
function detectIE() {
// check 6-10
msie = parseInt((/msie (\d+)/.exec((navigator.userAgent).toLowerCase()) || [])[1]);
if (isNaN(msie)) {
// not 6-10, check 11
msie = parseInt((/trident\/.*; rv:(\d+)/.exec((navigator.userAgent).toLowerCase()) || [])[1]);
}
// will be a number if IE or NaN if not
if (msie) {
$('body').addClass('ie ie' + msie);
alert('ie' + msie);
}
}
detectIE();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment