Last active
August 29, 2015 14:24
-
-
Save Zillionx/0c2887396e00b4984309 to your computer and use it in GitHub Desktop.
OS client javascript 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
/* | |
To detect the operating system on the client machine, | |
analyze the value of navigator.appVersion or navigator.userAgent. | |
This script sets the variable OSName to reflect the actual client OS. | |
*/ | |
var OSName="Unknown OS"; | |
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows"; | |
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS"; | |
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX"; | |
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux"; | |
document.write('Your OS: '+OSName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment