JQuery 1.9 removes $. Browser and replaces it with $. Support

  • 2020-03-30 03:52:10
  • OfStack

$. Browser determines the browser version and type by matching the userAgent with a regular expression. Jquery. Browser and jquery. Browser.

Determine 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, etc.

Check for IE6:


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

Check if it is IE 6-8:


if (!$.support.leadingWhitespace) {}

It is not recommended to use the browser type and version for this purpose.


Related articles: