Why is navigator.cpuClass incorrect?
I am trying to acquire the CPU type of visitors from Javascript using navigator.cpuClass in order to offer them the correct download. In my tests I have run into an example of navigator.cpuClass returning "Win32" when expect "Win64". The systeminfo utility on my PC returns:
Intel64 Family 6 Model 15 Stepping 11 GenuineIntel ~2400 Mhz (Q6600) which is further described at: http://ark.intel.com/Product.aspx?id=29765
Can anyone tell me why Javascript is not se开发者_JAVA百科eing a 64 bit CPU? I need to reliably detect that CPU...
Perhaps you are using a 32 bit browser. Trying out the samples from here, I get the same results (Win32
) even though I'm running a 64 bit OS (with a 32 bit build of Chrome).
However, in my case, Chrome's appVersion
string indicates that it runs under the Wow64 emulation layer. Perhaps you can find such hints for others browsers as well.
Generally, you can't detect the CPU class reliably because you never know whether your browser took the red or the blue pill.
A pragmatic solution would be to offer a default choice based on what your browser returns, and allow the user to switch to a 64 bit version. Since most 32 bit software runs flawlessly in a 64 bit environment (as proved by this case), most users won't notice if they pick the 'wrong' download.
精彩评论