Created
October 7, 2016 21:31
-
-
Save Donmclean/e6b4d032ec2834e846785866c8422898 to your computer and use it in GitHub Desktop.
Detect operating system from browser
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
var OSName="Unknown OS"; | |
if (navigator.appVersion.indexOf("Windows NT 6.2")!=-1) OSName="Windows 8"; | |
if (navigator.appVersion.indexOf("Windows NT 6.1")!=-1) OSName="Windows 7"; | |
if (navigator.appVersion.indexOf("Windows NT 6.0")!=-1) OSName="Windows Vista"; | |
if (navigator.appVersion.indexOf("Windows NT 5.1")!=-1) OSName="Windows XP"; | |
if (navigator.appVersion.indexOf("Windows NT 5.0")!=-1) OSName="Windows 2000"; | |
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="Mac/iOS"; | |
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX"; | |
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux"; | |
console.log('Your OS: '+OSName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment