Detect 64-bit or 32-bit Windows from User Agent or Javascript?
I want to offer the right version of a download. The versions I have are:
- 32-bit Windows
- 64-bit Windows
- Linux
Detecting Linux using the User Agent field is easy; but is it possible to reliably figure out if Windows is 32-bit or 64-bit?
Users might be using weird browsers - IE and Firefox are common, and we probably have an Opera user somewhere; maybe a Chrome user too. I know that 64-bit Windows 7 ships with 32-bit and 64-bit versions of IE, and I'd like to send them both the 64-bit version of my download.
(Edited to add: I know that I should provide all the options, and I will. But people don't read the options. So I wanted to provide the right download by default, to improve usability. Of course, while this is helpful if I get it right, it's extremely unhelpful if I get it wrong. And from the answers so far, it doesn't look like there's a reliable way of doing this).
Try this, looks for WOW64 (32-bit on 64-bit) or Win64 (native 64-bit) in the user-agent string.
if (navigator.userAgent.indexOf("WOW64") != -1 ||
navigator.userAgent.indexOf("Win64") != -1 ){
alert("This is a 64 bit OS");
} else {
alert("Not a 64 bit OS");
}
I've done some tests. Here are the results, hope it helps:
64 bit MacOS + 64 bit Safari or 32 bit Chrome: window.navigator.platform=MacIntel 32 bit windows + safari: window.navigator.platform=Win32 64 bit Windows + 64 bit IE: window.navigator.platform=Win64 window.navigator.cpuClass=x64 64 bit Windows + 32 bit IE: window.navigator.platform=Win32 window.navigator.cpuClass=x86 64 bit Windows + 32 Firefox (or Chrome): window.navigator.platform=Win32 32 bit linux mint (i686) + firefox: window.navigator.platform=Linux i686 64 bit Ubuntu (x86_64) + 32 bit Chrome: window.navigator.platform=Linux i686 64 bit Ubuntu + 64 bit Epiphany: window.navigator.platform=Linux x86_64
So far i've used this code:
deployJava.isWin64OS = function() {
return navigator.userAgent.indexOf('WOW64')>-1 || window.navigator.platform=='Win64';
};