How to write a website, that determines, if the user browses using a Server version of Windows?
Example:
- If the user uses
Windows Server 2016
=>Server
- If the user uses
Windows 10
=>not Server
How to write a website, that determines, if the user browses using a Server version of Windows?
Example:
Windows Server 2016
=> Server
Windows 10
=> not Server
You can use navigator.userAgent
which will return a string containing various pieces of information, for example on my machine:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
So then we can do:
function getOS() {
if (navigator.userAgent.includes('NT 10.0')) {
return 'Win10';
} else if (navigator.userAgent.includes('NT 8.1')) {
return 'Win8.1';
}
//etc...
}
Using javascript this can be easily done. See the following link: Can I use JavaScript to detect the operating system on the client machine
Using java you could use System.getProperty("os.name")
but this does not server your purpose since this will give you the operating system at which java is running which would be the OS of the server
I just found out this one which I think it solves your problem: