admin管理员组

文章数量:1290960

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.

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.

Share Improve this question asked Nov 28, 2014 at 12:05 Jasna TrengoskaJasna Trengoska 1311 silver badge3 bronze badges 7
  • Can't you find that info in the UA string? – PeeHaa Commented Nov 28, 2014 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 Commented Nov 28, 2014 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 Commented May 14, 2015 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 Commented May 19, 2015 at 11:12
  • 1 In that case, there's other related questions: stackoverflow./questions/28766423/… – Sam Hanley Commented May 19, 2015 at 12:38
 |  Show 2 more ments

3 Answers 3

Reset to default 6 +100

For extensive discussion of this question, see

  • Detect 64-bit or 32-bit Windows from User Agent or Javascript?
  • What is the list of possible values for navigator.platform as of today?

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.

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

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"

本文标签: javascriptDetect if Chrome browser installation is 64bitStack Overflow