Skip to content

Instantly share code, notes, and snippets.

@devinrhode2
Created May 31, 2019 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devinrhode2/4d608740597382eddb450d959505cabf to your computer and use it in GitHub Desktop.
Save devinrhode2/4d608740597382eddb450d959505cabf to your computer and use it in GitHub Desktop.
formatting for 1st answer on https://stackoverflow.com/questions/31757852/how-can-i-detect-internet-explorer-ie-and-microsoft-edge-using-javascript/32107845
const ieVersionInt = (function getIEVersionInt(){
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer') {
let ua = navigator.userAgent,
re = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");
if (re.exec(ua) !== null){
rv = parseFloat( RegExp.$1 );
}
} else if(navigator.appName == "Netscape"){
// in IE 11 the navigator.appVersion says 'trident'
// in Edge the navigator.appVersion does not say trident
if (navigator.appVersion.indexOf('Trident') === -1) rv = 12;
else rv = 11;
}
return rv;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment