Distinguish Chrome from Safari using jQuery.browser

Since Sarfraz has not corrected his answer (thank you Sarfraz for pointing me in the correct direction), I will post functioning code here. var userAgent = navigator.userAgent.toLowerCase(); $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); // Is this a version of Chrome? if($.browser.chrome){ userAgent = userAgent.substring(userAgent.indexOf(‘chrome/’) +7); userAgent = userAgent.substring(0,userAgent.indexOf(‘.’)); $.browser.version = userAgent; // If it is chrome then jQuery … Read more

How do you detect between a Desktop and Mobile Chrome User Agent?

The problem is the user agent will always have “Chrome” whether it is the desktop or mobile version. So you have to check the more specific case first. $(document).ready(function(){ var ua = navigator.userAgent; if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(ua)) $(‘a.mobile-other’).show(); else if(/Chrome/i.test(ua)) $(‘a.chrome’).show(); else $(‘a.desktop-other’).show(); });

Detecting IE6 using jQuery.support

While it’s good practice to check for feature support rather then user agent, there’s no simple way to check for something like support of a css property using JavaScript. I recommend you either follow the above posters suggestion of using conditional comments or use jQuery.browser. A simple implementation (not validated for performance or bugs) could … Read more

How to determine if a Promise is supported by the browser

Update Dec 11 – 2016: All evergreen versions of browsers now support promises. They are safe to use. Update Nov 14 – 2016: Chrome, Firefox, Safari and IE all now have experimental support for promises in their dev channels. The specification has settled. I would still not rely on the implementation just yet and would … Read more

How to target Edge browser with javascript

Try to detect features instead of a specific browser. It’s more future-proof. Only rarely should you use browser detection. With that out of the way: one option is to use a library (there are many intricacies to User Agent strings), or alternatively to parse window.navigator.userAgent manually. Using a parser library # https://github.com/faisalman/ua-parser-js. var parser = … Read more

Javascript IE detection, why not use simple conditional comments? [duplicate]

James Padolsey put a little snippet on GitHub that I’ll quote here: // ———————————————————- // A short snippet for detecting versions of IE in JavaScript // without resorting to user-agent sniffing // ———————————————————- // If you’re not in IE (or IE version is less than 5) then: // ie === undefined // If you’re in … Read more

tech