To detect the operating system on the client machine, you can use
The Navigator appVersion property is a read-only property and it returns a string that represents the version information of the browser.
<script> function operatingSytem() { 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"; // Display the OS name document.getElementById("OS").innerHTML = OSName; } </script>
JavaScript interview questions are gathered for people who are applying for JS jobs. JavaScript was created by Brendan Eich in… Read More