16

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 Answers 3

24

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.

Sign up to request clarification or add additional context in comments.

10 Comments

navigator.userAgent should contain this string(NT 5.1) also in Firefox.
@Dr.Molle Could you test it? Put javascript:alert(navigator.appVersion) in the address-bar of Firefox and press ENTER. It could be that my Firefox installation is corrupted somehow (because I'm running 3.6 and 4beta at the same time)
My Firefox returns for appVersion 5.0 (Windows; de) . I'm using 3.6.11 on WinXP. navigator.userAgent returns a string containing the needed information NT 5.1
@Šime Vidas: FF3.6.11 on winxp pro sp3: 5.0 (Windows; en-US)
Windows 8 is NT 6.2, just saying.
|
2

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

6 Comments

I tried finding more information and I found this w3schools.com/jsref/prop_nav_platform.asp which is not very well-documented. Is there better documentation out there for navigator.platform? EDIT: Looks like, according to developer.mozilla.org/en/DOM/window.navigator.platform, you cannot detect specific OS versions within Windows
I haven't been able to find much, but here's something I did find: code.google.com/p/doctype/wiki/NavigatorPlatformProperty EDIT: Firefox/Gecko reference: developer.mozilla.org/en/DOM/window.navigator.platform
@user396449 You have to search for the MSDN (IE) and MDC (Firefox) articles: msdn.microsoft.com/en-us/library/ms534340(v=VS.85).aspx and developer.mozilla.org/en/DOM/window.navigator.platform
@Tim & @Šime: Neither of those articles are able to detect specific versions of Windows
@user394669 Take a look at my answer. With navigator.appVersion you are able to detect the Windows version (NT 6.1 for Win7, etc.) in all browsers except Firefox
|
1
window.navigator.appVersion.split("NT")[1].split(";")[0].trim()

Will return the Windows version.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.