如何使用jQuery检测IE 8? [英] How do I detect IE 8 with jQuery?
问题描述
我不仅要检测浏览器类型,还需要使用jQuery检测版本。
大多数情况下我需要知道它是否是IE 8。
I need to detect not only the browser type but version as well using jQuery. Mostly I need to find out if it is IE 8 or not.
我不确定我是否正确使用它。
I am not sure if I am doing it correctly.
如果我这样做:
if (jQuery.browser.version >= 8.0) {
dosomething}
我不确定它适用于版本8.123.45.6还是会?
I am not sure it will work for version 8.123.45.6 or will it?
编辑:请注意,JQuery 2+已经放弃了对IE8及更低版本的支持,因此无法再用于检测IE8。如果使用当前版本的JQuery,则必须使用非JQuery解决方案。
推荐答案
这是记录在 jQuery API文档中。使用 $。browser.msie
检查Internet Explorer,然后使用 $。browser.version
检查其版本。
It is documented in jQuery API Documentation. Check for Internet Explorer with $.browser.msie
and then check its version with $.browser.version
.
自jQuery 1.3以来,jQuery.browser()方法已被弃用并在1.9中删除。 如果需要,它可以作为jQuery Migrate插件的一部分使用。我们建议对像Modernizr这样的库使用特征检测。
这篇关于如何使用jQuery检测IE 8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!