bit or 32

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).


    试试这个,在用户代理字符串中查找WOW64(32位,64位)或Win64(本机64位)。

    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';
    };
    

    Analysing around 14000 unique user-agents (from here), I've come up with the following strings to look for:

  • x86_64
  • x86-64
  • Win64
  • x64; (Mind the semicolon! Without it you will have false-positives.)
  • amd64
  • AMD64
  • WOW64
  • x64_64
  • Additionally, although they have different instruction sets and are not compatible with Intel x86_64, you may want to detect the following:

  • ia64
  • sparc64
  • ppc64
  • IRIX64
  • Beware though, don't just look for anything containing "64" or even "x64". Chrome's build numbers, spiders/bots, libraries, .NET versions, resolutions, etc. may also contain the string "x64" while still being a 32-bits (or other) OS.

    Note that you can search for all those strings case-insensitively.

    I have not been able to find anything on ARM. Perhaps someone else? Please edit, it is a community wiki.

    链接地址: http://www.djcxy.com/p/51908.html

    上一篇: 确定使用'dev'浏览器版本的网站访问者

    下一篇: 位或32