使用JavaScript检测Windows版本

ree*_*ine 16 javascript

具体来说,我试图检测Windows XP用户,因为它们与我的软件不兼容.

有没有办法检测至少70%或更高的准确度?

Šim*_*das 24

尝试 navigator.appVersion

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

我在这里有Windows 7,并navigator.appVersion在这些浏览器中返回包含"NT 6.1"的字符串:Chrome,Opera,Safari,IE9 beta.

只有Firefox不会在该字符串中返回该信息:(

顺便说一下,WinXP是"NT 5.1",Vista是"NT 6.0"......

更新

navigator.userAgent在所有5个浏览器中返回"NT版本"字符串.这意味着userAgent该属性能够告诉Windows版本.

  • Windows 8是"NT 6.2",只是说. (2认同)