jqueryexample.com jQuery - distinguish Chrome and Safari - jqueryexample.com

jQuery – distinguish Chrome and Safari by jqueryuser

I faced one situation in which I need to pass different value in chrome and safari.
As both the browsers have exactly the same userAgent string, both are fully based on webkit.

$(document).ready(function(){

$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
if($.browser.chrome){
    alert("chrome");

  userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7);
  userAgent = userAgent.substring(0,userAgent.indexOf('.'));
  version = userAgent;

     }

$.browser.safari = /safari/.test(navigator.userAgent.toLowerCase()); 
if($.browser.safari){
    alert("safari");
     }

});
Did you like this? Share it:

Discussion

No comments yet, be the first.

Leave a Comment