Last active
April 13, 2016 11:57
-
-
Save tiberiur/4a043aca28d0d8ac80c8 to your computer and use it in GitHub Desktop.
[JS] Get the browser name using navigator object
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
function getBrowserName() | |
{ | |
lsBrowser = navigator.userAgent; | |
if ( lsBrowser.indexOf("MSIE") >= 0 ) { | |
lsBrowser = "MSIE"; | |
} else if ( lsBrowser.indexOf("Firefox") >= 0 ) { | |
lsBrowser = "Firefox"; | |
} else if ( lsBrowser.indexOf("Chrome") >= 0 ) { | |
lsBrowser = "Chrome"; | |
} else if ( lsBrowser.indexOf("Safari") >= 0 ) { | |
lsBrowser = "Safari"; | |
} else if ( lsBrowser.indexOf("Opera") >= 0 ) { | |
lsBrowser = "Opera"; | |
} else { | |
lsBrowser = "UNKNOWH"; | |
} | |
return lsBrowser; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment