Skip to content

Instantly share code, notes, and snippets.

@stewhouston
Created May 28, 2016 05:34
Show Gist options
  • Save stewhouston/bf8ab67e0adc64b15e208ce12809c1e8 to your computer and use it in GitHub Desktop.
Save stewhouston/bf8ab67e0adc64b15e208ce12809c1e8 to your computer and use it in GitHub Desktop.
Detect Internet Explorer/Edge with JavaScript userAgent string sniffing. Silly spoofers.
var isIE = (function() {
var ua = navigator.userAgent,
ieMatches = [/Edge\/[0-9\.]+$/, /MSIE/, /Trident\/[0-9\.]+/];
for(var i = 0, len = ieMatches.length; i < len; i++) {
if (ua.match(ieMatches[i])) {
return true;
}
}
return false;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment