Created
June 26, 2014 20:42
-
-
Save jkrehm/d0671e7a9268eab6692d to your computer and use it in GitHub Desktop.
Detect operating system in JavaScript via the navigator's version
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
var mac = /mac/i.test(navigator.appVersion); | |
var ios = /(iphone|ipad)/i.test(navigator.appVersion); | |
var win = /(win)/i.test(navigator.appVersion); | |
var wp = /windows phone/i.test(navigator.appVersion); | |
var unix = /(linux|x11)/i.test(navigator.appVersion); | |
var android = /android/i.test(navigator.appVersion); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment