JQuery 1.9 removed $. browser, which can be replaced by $. support. jquery. browser

Source: Internet
Author: User

JQuery 1.9 removed $. browser, which can be replaced by $. support. jquery. browser

$. Browser uses regular expressions to match userAgent to determine the browser version and type. jquery has been declared in the jquery1.3.2 document. browser and jquery. browser. we recommend that you discard the version. You can use jquery. support.

JQuery removed $. browser and $. browser. version from version 1.9 and replaced it with $. support. In the latest version 2.0, IE 6/7/8 is no longer supported. Later, if you need to support IE 6/7/8, you can only use jQuery 1.9 or jQuery 1.10.1. 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]-->

For a long time, this will facilitate processing separately based on browser features in complex cases, rather than simply detecting browser types and versions. However, at present, many old programs cannot be transplanted directly to support the features of the browser, so I have found some solutions that can be replaced directly on the Internet.

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 after the equal sign returns true/false, which can be directly used to replace the original $. browser. msie.

Check whether IE6 is used:

// Oldif ($.browser.msie && 7 > $.browser.version) {}// Newif ('undefined' == typeof(document.body.style.maxHeight)) {}

Check whether it is IE 6-8:

if (!$.support.leadingWhitespace) {}

We do not recommend that you use the browser type and version for determination.


JQuery 19 does not support $ browser to determine the browser type and version.

JQuery removed $. browser and $. browser. version from version 1.9 and replaced it with $. support. In the latest version 2.0, IE 6/7/8 is no longer supported. Later, if you need to support IE 6/7/8, you can only use jQuery 1.9. To fully support IE and mix jQuery 1.9 and 2.0, the official Solution
JQuery removed $. browser and $. browser. version from version 1.9 and replaced it with $. support. In the latest version 2.0, IE 6/7/8 is no longer supported. Later, if you need to support IE 6/7/8, you can only use jQuery 1.9. To fully support IE and mix jQuery 1.9 and 2.0, the official solution is:
<! -- [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] -- for a long time, the zero point technology is conducive to processing browser features separately in complex cases, rather than simply detecting browser types and versions. However, at present, many old programs cannot be transplanted directly to support the features of the browser, so I have found some solutions that can be replaced directly on the Internet.
Determine the browser type:
Content from qishi Technology
$. 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 after the equal sign returns true/false, which can be directly used to replace the original $. browser. msie.
Check whether it is IE6 // Oldif ($. browser. msie & 7 $. browser. version) {} // Newif ('undefined' = typeof (document. body. style. maxHeight )){}
Check whether it is IE 6-8
If (! $. Support. leadingWhitespace ){}

What is the biggest difference between jQuery18 and 19?

The main differences between 1.9 and 1.8 are:

XSS Protection
If the $ () method is passed in the <script> tag, you can create HTML elements and run the script. Developers sometimes forget this and pass the resources obtained from unsafe locations into jQuery, resulting in cross-site-scripting (XSS) attacks. In jQuery
In 1.9, the $ () method restricts the input rules more strictly. A string is considered as HTML only when the first letter is the "<" symbol. Otherwise, it is considered as a CSS selector.

Remove $. browser, $. sub
$. Browser is deprecated in jQuery 1.3 and will be deprecated in jQuery
1.9 is removed. Developers can switch to $. support or directly read navigator. userAgent.

$. Sub is discarded in jQuery 1.7.
1.9 is removed. This function creates a copy of jQuery. modifying its attributes or methods does not affect the original jQuery object. But this function has not been proved to be useful, so it is moved to the 1.9 compatible plug-in. In this way, jQuery
The size of the 1.9 file will be smaller.

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.