how to detect the OS version like windows NT 6.1 will give 6.1, windows NT 5.1 will give 5.1 using javascript
-
This may help: stackoverflow.com/questions/11219582/…winseybash– winseybash2015-03-27 11:33:26 +00:00Commented Mar 27, 2015 at 11:33
-
that is using index of with NT 6.1, but is it possible to get 6.1 without adding it to index of like get version?Garima Garg– Garima Garg2015-03-27 11:38:51 +00:00Commented Mar 27, 2015 at 11:38
Add a comment
|
2 Answers
To detect the operating system on the client machine, your script can analyze the value of navigator.appVersion or navigator.userAgent. Below is a simple example of a script that sets the variable OSName to reflect the actual client OS. for example,
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";
document.write('Your OS: '+OSName);
1 Comment
Quentin
The question is specifically asking for the version not the platform.