使用JavaScript检测Google Chrome

As we all know, Google's Chrome browser hit the web yesterday. Whether you wanted to or not, you definitely downloaded Google's effort to see what ingenuity they put into their browser. It's clean, fast, and more stable than Firefox has been for me lately. Of course, there's always a chance that Chrome will have a quirk that none of the other browsers have and you may need to use client side detection to fix the problem. You can detect Chrome by using the following bit of JavaScript:

众所周知,Google的Chrome浏览器是昨天在网上发布的。 无论您是否愿意,您都一定下载了Google的工作成果,以了解他们在浏览器中的独创性。 它比Firefox最近对我来说干净,快速且稳定。 当然,Chrome总是有可能会出现其他浏览器都没有的怪癖,您可能需要使用客户端检测来解决此问题。 您可以使用以下JavaScript来检测Chrome:

var is_chrome = window.chrome;

The following string represents Chrome's full user agent:

以下字符串代表Chrome的完整用户代理:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13

Have any Chrome-specific functionality you want to build? Maybe a MooTools slide-in script that says "Hey, you're using Google's new browser!" It's probably too soon to try to fix Chrome-related bugs, but knowing how to detect it sooner rather than later is a good thing.

您要构建任何特定于Chrome的功能吗? 也许是MooTools的滑入脚本,上面写着“嘿,您正在使用Google的新浏览器!” 尝试修复与Chrome相关的错误可能为时过早,但是知道如何尽早检测出它是一件好事。

翻译自: https://davidwalsh.name/detecting-google-chrome-javascript

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值