Skip to content

Instantly share code, notes, and snippets.

@Zillionx
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zillionx/0c2887396e00b4984309 to your computer and use it in GitHub Desktop.
Save Zillionx/0c2887396e00b4984309 to your computer and use it in GitHub Desktop.
OS client javascript detection
/*
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