Last active
November 18, 2022 11:38
-
-
Save jgphilpott/7d76cbfe92ecb86bc5206c6e8bd84906 to your computer and use it in GitHub Desktop.
A function for detecting a clients browser.
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
# Credit: https://stackoverflow.com/a/40246491/1544937 | |
getBrowser = -> | |
try | |
error.throw | |
catch error | |
error = error.toString().toLowerCase() | |
if error.includes "cannot read" | |
return "chrome" | |
if error.includes "not an object" | |
return "safari" | |
if error.includes "error is undefined" | |
return "firefox" | |
return "unknown" |
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
// Generated by CoffeeScript 2.7.0 | |
// Credit: https://stackoverflow.com/a/40246491/1544937 | |
var getBrowser; | |
getBrowser = function() { | |
var error; | |
try { | |
return error.throw; | |
} catch (error1) { | |
error = error1; | |
error = error.toString().toLowerCase(); | |
if (error.includes("cannot read")) { | |
return "chrome"; | |
} | |
if (error.includes("not an object")) { | |
return "safari"; | |
} | |
if (error.includes("error is undefined")) { | |
return "firefox"; | |
} | |
return "unknown"; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment