13

I am trying to perform a script that should run only on Chrome 64-bit version browsers. Is there a way to check using JavaScript if the Chrome version installed on a user's machine is 64-bit or 32-bit? t should be browser-specific, because for example I run a 64-bit OS and a 32-bit version of Chrome.

So far I managed to detect if the open browser is Chrome and what version of it using Bowser. But I am still struggling with the 64-bit browser detection.

Jasna Trengoska
  • 131
  • 1
  • 3
  • Can't you find that info in the UA string? – PeeHaa Nov 28 '14 at 12:09
  • This is an example of such string: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 And here WOW64 points at a 32-bit version, but then that is for Windows, and what about iOS and Linux? – Jasna Trengoska Nov 28 '14 at 13:00
  • 5
    Why are you needing to specifically detect the 64 bit Chrome? Are you sure whatever your problem is can't be worked around via feature detection instead? – Sam Hanley May 14 '15 at 13:43
  • @sphanley - NPAPI support (required by Shockwave, a plugin we use) has been removed from 64bit chrome, and disabled in 32 bit chrome. So if we know someone is in 32 bit chrome we can say "You can enable Shockwave by doing the following..." and if we know they are in 64 bit chrome we can say "You can't use Shockwave in chrome any more - please use a different browser". This is until september when it's removed from 32 bit chrome too. We are converting resources to be non-shockwave, but we're in a difficult transition period in the mean time, and need to give the most useful advice to users. – Max Williams May 19 '15 at 11:12
  • And, there seems to be no way to programmatically distinguish between a user who hasn't installed shockwave yet, and someone who HAS installed it but had it disabled via the NPAPI option. – Max Williams May 19 '15 at 11:13
  • 1
    In that case, there's other related questions: http://stackoverflow.com/questions/28766423/detecting-npapi-support-in-chrome-using-javascript – Sam Hanley May 19 '15 at 12:38
  • And if all you're doing in these cases is showing different messages, have you considered just showing a combined message that says "if you're using 32 bit Chrome, enable via [...], not supported in 64 bit"? Any user who's both technically savvy enough to bother messing around in their browser's settings so as to use a dated webapp can probably handle checking their Chrome version themself. – Sam Hanley May 19 '15 at 12:44

3 Answers3

6

For extensive discussion of this question, see

The bottom line is that the property you are looking for is navigator.platform, which returns the platform of the browser, not the operating system.

You might also take a look at platform.js, a platform detection library.

EDIT

After looking into this further, it seems that while navigator.platform should reflect the browser platform, the actual value returned is not always useful.

For example, on Windows, both the 32-bit and 64-bit versions return "Win32". In that case, the user agent string has the better value of either WOW64 for the 32-bit browser or x64 for 64-bit.

Ultimately it seems like the better solution is to rely on canonical lists like in the linked questions, or use a library like platform.js.

Community
  • 1
  • 1
Sarah Elan
  • 2,465
  • 1
  • 23
  • 45
  • navigator.platform relates to the OS, doesn't it, rather than the version of Chrome? I've looked at platform.js and it just picks apart the userAgent string too. The really annoying problem is that if you go to the "About" page it has the version, and then "(64 bit)" after it, if it's the 64 bit version of chrome. But this extra bracketed bit isnt' added into the userAgent string. – Max Williams May 14 '15 at 08:36
  • WOW64 is actually very valuable information - if you see it you know that the OS is 64 bit and Chrome is 32 bit. What i've ended up doing is saying "If we can see WOW64 it's 32 bit chrome. Otherwise 1) is it Windows? If it's windows can we see 64 in the OS part? If so then it's 64 bit chrome. If not then it's 32 bit chrome. 2) Is it Mac? Not so easy to tell on mac..." – Max Williams May 19 '15 at 09:00
  • I'm giving the bounty to this answer as it pointed me at WOW64 which was key. I need to refactor my code a bit and then i will post my own answer including my js functions. – Max Williams May 19 '15 at 13:04
0

Based on what I've found, you should try looking for the following strings

  • x86_64
  • x86-64
  • Win64
  • x64; (Mind the semicolon! Without it you will have false-positives.)
  • amd64
  • AMD64
  • WOW64
  • x64_64
-1

navigator.userAgent containes "WOW64" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.65 Safari/537.36"

A dev
  • 930
  • 3
  • 12
  • 27
  • See the asker's [comment](http://stackoverflow.com/questions/27188292/detect-if-chrome-browser-installation-is-64-bit#comment-42864555) above. – Sarah Elan May 18 '15 at 19:00