Detect Windows Version With JavaScript

后端 未结 3 1154
攒了一身酷
攒了一身酷 2020-12-30 03:20

Specifically, I am trying to detect Windows XP users as they are not compatible with my software.

Is there a way to detect with at least 70% or higher accuracy?

相关标签:
3条回答
  • 2020-12-30 04:11
    window.navigator.appVersion.split("NT")[1].split(";")[0].trim()
    

    Will return the Windows version.

    0 讨论(0)
  • 2020-12-30 04:14

    Try navigator.appVersion

    http://msdn.microsoft.com/en-us/library/ms533080(v=VS.85).aspx
    https://developer.mozilla.org/en/DOM/window.navigator.appVersion

    I have Windows 7 here and the navigator.appVersion returns a string containing "NT 6.1" in these browsers: Chrome, Opera, Safari, IE9 beta.

    Only Firefox does not return that info in that string :(

    btw, WinXP is "NT 5.1", Vista is "NT 6.0" ...

    Update

    navigator.userAgent returns the "NT version" string in all 5 browsers. That means that userAgent is the property that is able to tell the Windows version.

    0 讨论(0)
  • 2020-12-30 04:18

    It appears that you can use the navigator host object:

    var os = navigator.platform
    

    See here for more info: http://www.jguru.com/faq/view.jsp?EID=1100686

    Also: http://www.quirksmode.org/js/detect.html

    0 讨论(0)
提交回复
热议问题