JQuery 1.9 USES $. Support instead of $. Browser

  • 2020-03-30 03:06:17
  • OfStack

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. If you need to check if it is IE6, you can write:


// 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) {} 

The ultimate solution is to replace it with another library, with an article written by a foreigner:

(link: http://www.quirksmode.org/js/detect.html)


Related articles: