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 can be used. If you want to fully support IE and mix jQuery 1.9 and 2.0, the official solution is:
Copy Code code as follows:
<!--[If Lt IE 9]>
<script src= ' jquery-1.9.0.js ' ></script>
<! [endif]-->
<!--[if GTE IE 9]>
<script src= ' jquery-2.0.0.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:
Copy Code code as follows:
$.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. If you need to check for IE6, you can write this:
Copy Code code as follows:
Old
if ($.browser.msie && 7 > $.browser.version) {}
New
if (' undefined ' = = typeof (Document.body.style.maxHeight)) {}
Check for IE 6-8:
Copy Code code as follows:
if (!$.support.leadingwhitespace) {}
The ultimate method is to use another class library instead, you can refer to an article written by foreigners:
Browser Detect