在Javascript中,如何确定我当前的浏览器是否是计算机上的Firefox与其他所有浏览器? [英] In Javascript, how do I determine if my current browser is Firefox on a computer vs everything else?
问题描述
if(firefox and is on a computer){
alert('using firefox on a computer')
}else{
alert("using something else!");
}
我该怎么做?
推荐答案
您所追求的是浏览器检测:
What you're after is known as browser detection:
if ($.browser.mozilla) { ...
然而,不鼓励浏览器嗅探,因为它容易欺骗用户代理,即伪装成另一个浏览器!
However, browser sniffing is discouraged, as its easy to spoof the user agent, i.e. pretend to be another browser!
您最好使用功能检测,以您自己的方式,或通过 jQuery.support
interface: http://api.jquery.com/ jQuery.support/
You'd best use feature detection, either in your own way, or through the jQuery.support
interface: http://api.jquery.com/jQuery.support/
这是一篇关于扩展它以供自己使用的文章:
http://www.waytoocrowded.com/2009/03/14/jquery-supportminheight/
Here's an article on extending it for your own use: http://www.waytoocrowded.com/2009/03/14/jquery-supportminheight/
修改:
发现这篇文章也有帮助:当IE8不是IE8什么是$ .browser.version?
Found this post as well which helps: When IE8 is not IE8 what is $.browser.version?
这篇关于在Javascript中,如何确定我当前的浏览器是否是计算机上的Firefox与其他所有浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!