JavaScript Operating System detection

The Window.navigator read-only property returns a reference to the Navigator object, which can be queried for information about the application running the script. The navigator.appVersion string should be used to find the name of the operating system on the client.
run this source code Browser View

Find Your Operating System

<!DOCTYPE html> <html> <head> <title>OS Examples</title> <script> function findOS() { var curOS="Not Nmaed..."; if (navigator.appVersion.indexOf("Win")!=-1) curOS="Windows"; if (navigator.appVersion.indexOf("Mac")!=-1) curOS="MacOS"; if (navigator.appVersion.indexOf("X11")!=-1) curOS="UNIX"; if (navigator.appVersion.indexOf("Linux")!=-1) curOS="Linux"; alert('Your OS: '+curOS); } </script> </head> <body> <h2>Find Your Operating System</h2> <p> <input type="button" value="Find Operating System" onclick="findOS()" /> </p> </body> </html>