How to detect the operating system on the client machine in JavaScript?
The navigator.appVersion string should be used to find the name of the operating system on the client machine.
The following code snippet returns the appropriate Operating systems. 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";
How to detect the operating system on the client machine in JavaScript?
navigator.platform returns the platform on which the browser is running.