Last active
August 29, 2015 13:56
-
-
Save s-shin/9171790 to your computer and use it in GitHub Desktop.
Detect user agent by CoffeeScript. Public domain :)
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
| # ref: https://w3g.jp/blog/tools/js_browser_sniffing | |
| UA = | |
| ie: do -> | |
| ie = false | |
| ael = window.addEventListener? | |
| ie = 6 if ael and not document.documentElement.style.maxHeight? | |
| ie = 7 if not ie and ael and not document.querySelectorAll? | |
| ie = 8 if not ie and ael and not document.getElementsByClassName? | |
| ie = 9 if not ie and document.uniqueID and not window.matchMedia | |
| ie = document.documentMode if not ie and document.uniqueID | |
| ie | |
| firefox: "MozAppearance" of document.documentElement.style | |
| opera: window.opera? | |
| chrome: window.chrome? | |
| safari: not window.chrome? and \ | |
| "WebkitAppearance" of document.documentElement.style | |
| mobile: window.orientation? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment