Is there any kind of jQuery.browser fallback?

2019-07-17 05:23发布

问题:

As jQuery.browser has been removed since 1.9 I am getting a lot of trouble because so many plugins did not get updated and still use that function despite of its absence in current jQuery releases. Is there any recommended way to modify existing plugins or any other advice?

回答1:

jQuery.browser() removed:

The jQuery.browser() method has been deprecated since jQuery 1.3 and is removed in 1.9. If needed, it is available as part of the jQuery Migrate plugin. We recommend using feature detection with a library such as Modernizr

jQuery Migrate 1.1.1 Released:

Using the jQuery Migrate plugin is easy, just include it immediately after the script tag for jQuery, for example.

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.1.js"></script>


回答2:

http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed

jQuery.browser() removed

The jQuery.browser() method has been deprecated since jQuery 1.3 and is removed in 1.9. If needed, it is available as part of the jQuery Migrate plugin. We recommend using feature detection with a library such as Modernizr.

So it should be available here:

http://blog.jquery.com/2013/01/31/jquery-migrate-1-1-0-released/