Posted By

localhorst on 03/24/09


Tagged

browser jquery


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

LeslieOA
Cepreu


deprecated jQuery browser detection


 / Published in: JavaScript
 

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

bring back the old browser detection

  1. (function($) {
  2. var userAgent = navigator.userAgent.toLowerCase();
  3.  
  4. $.browser = {
  5. version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
  6. safari: /webkit/.test( userAgent ),
  7. opera: /opera/.test( userAgent ),
  8. msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
  9. mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
  10. };
  11.  
  12. })(jQuery);
  13.  
  14. if($.browser.safari) $("body").addClass("safari");

Report this snippet  

You need to login to post a comment.