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!