Skip to content

Instantly share code, notes, and snippets.

@tipiirai
Created January 16, 2013 04:13
Show Gist options
  • Save tipiirai/4544584 to your computer and use it in GitHub Desktop.
Save tipiirai/4544584 to your computer and use it in GitHub Desktop.
jQuery.browser for v1.9+
/*
jQuery.browser for 1.9+
We all love feature detection but that's sometimes not enough.
@author Tero Piirainen
*/
!function($) {
if (!$.browser) {
var b = $.browser = {},
ua = navigator.userAgent.toLowerCase(),
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) || [];
if (match[1]) {
b[match[1]] = true;
b.version = match[2] || "0";
}
}
}(jQuery);
@tipiirai
Copy link
Author

For example Safari prior to v5.1.14 has a broken WebSocket support

socketio/socket.io#193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment