deprecated jQuery browser detection


/ Published in: JavaScript
Save to your folder(s)

bring back the old browser detection


Copy this code and paste it in your HTML
  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");

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.