Created
May 31, 2019 17:08
-
-
Save devinrhode2/4d608740597382eddb450d959505cabf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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