Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the replacement for $.browser

The jQuery document tags $.browser as deprecated. So what's the replacement for it?

like image 911
Rocky Avatar asked Mar 10 '12 10:03

Rocky


People also ask

What will replace browsers?

Messaging apps are the new web browsers. Conversational apps are the new websites. Messaging apps are on track to rival web browsers, the main point of contact between brands and their customers.

What browser should I replace Chrome with?

Microsoft Edge. The new Microsoft Edge is built on the Chromium engine so it's as compatible as Chrome itself, but with that Microsoft spin.

What is another Internet browser?

Google Chrome, Microsoft Edge, and Opera. Mozilla Firefox. Internet Explorer.

What browser is not owned by Google?

DuckDuckGo. DuckDuckGo started its life as a search engine built to oppose Google's data collecting ways but has since branched out into browsers too.


1 Answers

Based on jQuery migration plugin , I found this.

jQuery.uaMatch = function( ua ) {     ua = ua.toLowerCase();     var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||         /(webkit)[ \/]([\w.]+)/.exec( ua ) ||         /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||         /(msie) ([\w.]+)/.exec( ua ) ||         ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || [];     return {         browser: match[ 1 ] || "",         version: match[ 2 ] || "0"     }; }; if ( !jQuery.browser ) {     var      matched = jQuery.uaMatch( navigator.userAgent ),     browser = {};     if ( matched.browser ) {         browser[ matched.browser ] = true;         browser.version = matched.version;     }     // Chrome is Webkit, but Webkit is also Safari.     if ( browser.chrome ) {         browser.webkit = true;     } else if ( browser.webkit ) {         browser.safari = true;     }     jQuery.browser = browser; } 
like image 84
takien Avatar answered Oct 02 '22 15:10

takien