Return to Snippet

Revision: 12691
at March 24, 2009 17:11 by localhorst


Initial Code
(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");

Initial URL
http://docs.jquery.com/Utilities/jQuery.browser

Initial Description
bring back the old browser detection

Initial Title
deprecated jQuery browser detection

Initial Tags
browser, jquery

Initial Language
JavaScript