Last active
September 19, 2016 19:38
-
-
Save bronzehedwick/e324e583f14df4b65fba to your computer and use it in GitHub Desktop.
Dumb browser detection...
This file contains hidden or 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
/** | |
* Determines (poorly) the current browser. | |
* @returns {string} the current browser or 'unknown'. | |
*/ | |
function getBrowser() { | |
var ua = navigator.userAgent; | |
var browsers = [ | |
'Vivaldi', | |
'OPR', // Opera | |
'Firefox', | |
'Chrome', | |
'Safari' | |
]; | |
for ( let i = 0, length = browsers.length; i < length; i++ ) { | |
if ( ua.includes( browsers[i] ) ) { | |
return browsers[i]; | |
} | |
} | |
return 'unknown'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment