Explain how to detect the operating system on the client machine?

Explain how to detect the operating system on the client machine?

Navigator objects helps in getting client’s OS info. You can use the following code snippet to get user 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";

alert('Your OS: '+OSName);