在客户端获取浏览器的名称 [英] Getting a browser's name client-side
本文介绍了在客户端获取浏览器的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何对象或方法返回有关浏览器的客户端数据?
Is there any object or method that returns data about the browser, client-side?
例如,我需要检测浏览器是否为IE(内部浏览器)。以下是代码段。
For example, I need to detect if the browser is IE (Interner Explorer). Following is the code snippet.
function isInternetExplorer()
{
if(navigator.appName.indexOf("Microsoft Internet Explorer") != -1)
{
return true;
}
return false;
}
有更好的方法吗?
推荐答案
编辑:由于答案对更高版本的jquery无效,因为jQuery.browser在1.9版中已弃用,因此请使用Jquery 迁移插件 。
Since the answer is not valid with newer versions of jquery As jQuery.browser is deprecated in ver 1.9, So Use Jquery Migrate Plugin for that matter.
原始答案
jQuery.browser
和
jQuery.browser.version
是您的理想之选。
这篇关于在客户端获取浏览器的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文