Check Chrome and Safari using jQuery

Use the following code:

var userAgent = navigator.userAgent.toLowerCase(); $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); // Is this a version of Chrome? if($.browser.chrome){ userAgent = userAgent.substring(userAgent.indexOf('chrome/') +7); userAgent = userAgent.substring(0,userAgent.indexOf('.')); $.browser.version = userAgent; alert('chrome'); // If it is chrome then jQuery thinks it's safari so we have to tell it it isn't $.browser.safari = false; } // Is this a version of Safari? if($.browser.safari){ userAgent = userAgent.substring(userAgent.indexOf('safari/') +7); userAgent = userAgent.substring(0,userAgent.indexOf('.')); $.browser.version = userAgent; alert('safari');

Comments

Popular posts from this blog

Leap Year Calculator

PDF form validation using javascript

Localhost firefox asking for password and username