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

Drive are not opening in same window on double click in windows XP

Python commands for Mac and Windows

Unable to Start Debugging on the Web Server