JQuery 1.9 removed $.browser can be replaced with $.support _jquery

Source: Internet
Author: User

$.browser is a regular expression to match the useragent to determine the browser version and kind of the. jquery1.3.2 version of the document has been declared Jquery.browser and jquery.browser.version recommended deprecated, you can use the Jquery.suppo RT to replace.

JQuery starts with the 1.9 version, removing $.browser and $.browser.version, and substituting $.support. In the newer version 2.0, IE 6/7/8 will no longer be supported. Later, if the user needs to support IE 6/7/8, only jquery 1.9 or jquery 1.10.1 can be used. If you want to fully support IE and mix jQuery 1.9 and 2.0, the official solution is:

<!--[if Lt IE 9]>
<script src= ' http://keleyi.com/keleyi/pmedia/jquery-1.10.1.min.js ' ></script >
<![ Endif]-->
<!--[if GTE IE 9]>
<script src= ' http://keleyi.com/keleyi/pmedia/jquery-2.0.2.min.js ' ></script>
<![ Endif]-->

In the long run, this helps to deal with the browser's characteristics separately in complex situations, rather than simply detecting browser types and versions. However, many of the old program porting may not be directly to the browser support features, so on the Internet to find a number of direct replacement solutions.

To determine the browser type:

$.browser.mozilla =/firefox/.test (Navigator.userAgent.toLowerCase ());
$.browser.webkit =/webkit/.test (Navigator.userAgent.toLowerCase ());
$.browser.opera =/opera/.test (Navigator.userAgent.toLowerCase ());
$.browser.msie =/msie/.test (Navigator.userAgent.toLowerCase ());

The expression following the equal sign returns the True/false, which can be used directly to replace the original $.browser.msie, and so on.

Check for IE6:

Old
if ($.browser.msie && 7 > $.browser.version) {}
//New
if (' undefined ' = = typeof (document.b ody.style.maxHeight)) {}

Check for IE 6-8:

if (!$.support.leadingwhitespace) {}

It is not recommended to use browser types and versions for judgment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.