jQuery – distinguish Chrome and Safari

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");
     }
});
Share this nice post:

One thought on “jQuery – distinguish Chrome and Safari

Comments are closed.