使用Jquery代码获取当前浏览器名称 [英] Get Current Browser Name using Jquery code

查看:457
本文介绍了使用Jquery代码获取当前浏览器名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,当我使用navigator.userAgent.toLowerCase()时,我得到的输出如下:

Actually, When I am using navigator.userAgent.toLowerCase(), I get output like this :

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36

我不想要这个输出.但是我只想获取正在浏览的当前浏览器名称,并使用Jquery获取浏览器名称. 是否有任何功能仅获取当前浏览器名称而不是获取所有浏览器名称. 而且,当我在Google Chrome浏览器上浏览时,输出为"Chrome";当我使用Firefox浏览器浏览时,输出为Firefox.预先感谢.

I don't want this output. But I want to get only current browser name on which I am browsing and get browser name using Jquery. Is there any function to get only current browser name instead of getting all browser names. And, I get output "Chrome" when I am browsing on Google Chrome browser and, Firefox when I am browsing using Firefox Browser. Thanks in advance.

推荐答案

尝试一下:

Object.keys(jQuery.browser)[0]

在使用此功能之前,必须先加载此jQuery

Before you used this you must be load this jquery

<script src="https://code.jquery.com/jquery-migrate-1.3.0.js"></script>

因为 jQuery.browser 不能在 jQuery 1.9 或更高版本中使用,除非包含jQuery Migrate插件.

because jQuery.browser Will not work in jQuery 1.9 or later unless the jQuery Migrate plugin is included.

这篇关于使用Jquery代码获取当前浏览器名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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