/ Published in: JavaScript
bring back the old browser detection
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(function($) { var userAgent = navigator.userAgent.toLowerCase(); $.browser = { version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], safari: /webkit/.test( userAgent ), opera: /opera/.test( userAgent ), msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) }; })(jQuery); if($.browser.safari) $("body").addClass("safari");
URL: http://docs.jquery.com/Utilities/jQuery.browser