How to detect the operating system on the client machine in JavaScript?

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.
How to set a HTML document's background color in JavaScript?
How to set a HTML document's background color? - ...
How do you assign object properties?
Java script object properties are assigned like assigning a value to a variable...
What is JavaScript?
JavaScript is a scripting language most often used for client-side web development...
Post your comment