检测 Rails 中的操作系统和 32 或 64 位处理器
抱歉,如果这看起来是一个简单的问题,但对我来说事实并非如此!我对 Ruby 和 Rails 还很陌生,所以请耐心等待。
在网页上,我试图根据访问该网站的人的操作系统创建自定义下载链接,我想知道是否可以确定该人运行的是 32 位还是 64 位处理器。这是否包含在用户代理中的某个地方而我太愚蠢而看不到它?或者,如果有一个宝石可以为我做到这一点,但我只是不知道,请告诉我。
预先感谢您的任何帮助。
干杯, 肖恩
Sorry if this seems like a simple question but to me it isn't! I am still pretty new to Ruby and Rails so please bear with me.
On a webpage, I am trying to make a customized download link depending on the OS of the person accessing the website and I was wondering if it is possible to determine if the person is running a 32 or 64 bit processor. Is this included in the user agent somewhere and I am just too daft to see it? Or if there is a gem out there that does this for me and I just don't know about it please let me know.
Thanks in advance for any help.
Cheers,
Sean
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅通过查看标题,您无法在 100% 的时间做出 100% 的决定,但有时您可以使用标题。以下是 Microsoft 关于用户代理字符串的说法:
了解用户代理字符串:
http://msdn.microsoft.com/en -us/library/ms537503(v=vs.85).aspx
您还可以在用户的浏览器上运行 Javascript,并将结果回发到服务器以获得更准确的结果。请参阅此处有关同一主题的讨论:
从用户代理或 Javascript 检测 64 位或 32 位 Windows?
You can not make a 100% decision 100% of the time from just looking at the headers, but some of the time you can use the headers. Here's what Microsoft says about User Agent strings:
Understanding User-Agent Strings:
http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
You can also run Javascript on the user's browser and post back the result to the server for more accurate results. See here for a discussion on this same topic:
Detect 64-bit or 32-bit Windows from User Agent or Javascript?