不推荐使用 jQuery $.browser 吗? [英] Is jQuery $.browser Deprecated?

查看:36
本文介绍了不推荐使用 jQuery $.browser 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能告诉我我是否正确地认为 jQuery 的 $.browser 已/已被弃用?

Can someone tell me if I am correct in believing that jQuery's $.browser is/has been deprecated?

我现有的实现会继续工作吗?如果没有,是否有易于实施的替代方案.

Will my existing implementations continue to work? If not, is there an easy to implement alternative.

推荐答案

来自文档:

$.browser 属性在 jQuery 1.3 中已弃用,其功能可能会在 jQuery 的未来版本中移至团队支持的插件中.

The $.browser property is deprecated in jQuery 1.3, and its functionality may be moved to a team-supported plugin in a future release of jQuery.

所以,是的,它已被弃用,但您现有的实现将继续工作.如果删除了该功能,则很可能可以使用插件轻松访问它.

So, yes, it is deprecated, but your existing implementations will continue to work. If the functionality is removed, it will likely be easily accessible using a plugin.

至于是否有替代方案...答案是有,可能".使用 $.support 进行特征检测要好得多而不是浏览器检测:检测您需要的实际功能,而不是提供它的浏览器.可以检测到因浏览器而异的最重要功能.

As to whether there is an alternative... The answer is "yes, probably". It is far, far better to do feature detection using $.support rather than browser detection: detect the actual feature you need, not the browser that provides it. Most important features that vary from browser to browser are detected with that.

2013 年 2 月 16 日更新: 在 jQuery 1.9 中,删除了此功能 (文档).最好不要使用它.如果你真的,真的必须使用它的功能,你可以使用 jQuery 恢复它迁移插件.

Update 16 February 2013: In jQuery 1.9, this feature was removed (docs). It is far better not to use it. If you really, really must use its functionality, you can restore it with the jQuery Migrate plugin.

这篇关于不推荐使用 jQuery $.browser 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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