JQuery appears cannot read property ' MSIE ' of undefined error resolution _jquery

Source: Internet
Author: User
Tags jquery library

JQuery cannot read property ' MSIE ' of undefined error resolution

Recently upgraded a project jquery to the latest version and found that some pages reported the following error

Cannot read property ' Msie ' of undefined

On the jquery site search, the reason is $.browser this API from the beginning of the jQuery1.9 formally abolished, JS code as long as the use of $.browser will report this error. Refer to the official jquery statement.

The landlord conveniently expanded to read a bit and found that jquery 1.9 has officially deleted all APIs marked as deprecated in previous versions, completely no longer backwards compatible. For child shoes that are upgraded to the latest jquery, this means it takes some extra time to upgrade the code to use the new API, or implement the deleted methods yourself. Luckily, the jquery team realized the inconvenience of the break change and introduced a jquery migrate plug-in that would automatically restore the APIs that were discarded in the latest version. As long as the reference to this plug-in, the existing JS code without changes can be with the latest jquery library to run normally.

The following is a specific solution, first of all to download the jquery Migrate plug-in, and then refer to the jquery JS place after the reference to the jquery Migrate js file.

<script src= "Http://code.jquery.com/jquery-1.10.2.js" ></script>
<script src= "Http://code.jquery.com/jquery-migrate-1.2.1.js" ></script>

The jquery migrate solution, though simple and painless, will result in an additional JS library. For those who do not like to add additional JS Library of children's shoes, you can refer to this blog mentioned another solution, please note that the following code loading location: jquery file, $.browser before the code.

jquery.browser={};(function () {jquery.browser.msie=false; Jquery.browser.version=0;if navigator.userAgent.match ( /msie ([0-9]+)./)) ({jquery.browser.msie=true;jquery.browser.version=regexp.$1;}}) ();

Thank you for reading, I hope to help you, thank you for your support for this site!

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.