检测从用户代理或JavaScript 64位或32位Windows? [英] Detect 64-bit or 32-bit Windows from User Agent or Javascript?

查看:166
本文介绍了检测从用户代理或JavaScript 64位或32位Windows?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要提供正确的版本下载。我的版本是:

I want to offer the right version of a download. The versions I have are:

  • 在32位Windows
  • 在64位Windows
  • 的Linux

使用检测的Linux用户代理领域是容易的;但它能够可靠地计算出,如果Windows是32位还是64位?

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?

用户可能会使用奇怪的浏览器 - IE和Firefox是常见的,我们可能有一个歌剧用户某处;也许Chrome浏览器的用户了。我知道,64位Windows 7附带了32位和64位版本的IE浏览器,我想送他们两个64位的版本我下载。

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.

(编辑补充:我知道,我应该提供所有的选项,我会,但人不。 T上读。所以我想提供正确的下载默认情况下,以提高可用性的选项。当然,虽然这是有益的,如果我得到它的权利,这是非常无益的,如果我做错了,而且从答案到目前为止,它看起来并不像有这样做)的一个可靠的方法。

(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位)。

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");
}

这篇关于检测从用户代理或JavaScript 64位或32位Windows?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆