JQuery - determining the operating system and version of the operating system

For several months, I wrote an account for my company and just developed a main site for it with installation instructions for it (our employees are based all over the world, and very few have heard about user scripts, not to mention used them, therefore this interface is designed to reduce the time I spend supporting the script).

What I would like to do, on the installation page, determine which browser and OS / OS version they use, so that I can highlight the most important instructions, a little darker than the rest, or just not display irrelevant sections.

For example, for IE6 you should use Trixie (I suppose) to install custom scripts, and this is only supported in Win XP. IE7 is supported in Win XP, IE8 is supported in Win XP and Win 7, and IE9 is supported only on Win 7. For IE7, 8, and 9, I recommend using IEPro. The difference between Trixie and IEPro is that Trixie requires the .user.js file extension, which must be saved in C: / Program Files / bhelpuri. IEPro, on the other hand, requires the extension to be .ieuser and stored elsewhere. For IE, I would specifically like to detect the version and display only the correct link (either .user.js or .ieuser, depending on which plug-in they should use for their current browser) so that they are taken to the correct version of the file for this browser with the correct save path for this OS / OS version. Does it still make sense?

Basically, my question is: does anyone know a way to detect the version of the operating system? I am currently using http://www.stoimen.com/blog/2009/07/04/jquery-os-detection/ , but this does not give an OS version, but only an OS. I tried intercepting all the variables stored in the navigator object without success. Any help would be greatly appreciated.

Edit: Thanks Nates, I put the exact code http://jsfiddle.net/Mu8r5/1/ . Hope this helps someone in the future.

+6
source share
3 answers

It is best to use the navigator.userAgent property. It will give the version number of Windows. You can see a table of how the version number of Windows is displayed in the OS here:

OSVERSIONINFO

Here is an example discovery code:

var os = (function() { var ua = navigator.userAgent.toLowerCase(); return { isWin2K: /windows nt 5.0/.test(ua), isXP: /windows nt 5.1/.test(ua), isVista: /windows nt 6.0/.test(ua), isWin7: /windows nt 6.1/.test(ua), isWin8: /windows nt 6.2/.test(ua), isWin81: /windows nt 6.3/.test(ua) }; }()); if(os.isWin7) { ... } 

http://jsfiddle.net/45jEc/

+22
source

You can use this wonderful javascript library: http://www.visitorjs.com/details Recently it is open

Edit: Actually, it has now been renamed to session.js http://github.com/codejoust/session.js and as far as I know, this is the best you can get.

+5
source

Stack Overflow Question To find the exact OS version from the browser , there is interesting information on how to get the OS version from the User-Agent header, which, I believe, contains the same information that can be accessed from JavaScript.

+1
source

Source: https://habr.com/ru/post/905427/


All Articles