看来
jQuery.browser是能够识别webkit相当容易1.4。但是如何使用它来区分Chrome和Safari(反之亦然)?
解决方法
由于Sarfraz没有纠正他的答案(谢谢Sarfraz指向我的正确方向),我会在这里发布功能代码。
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; // 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('version/') +8); userAgent = userAgent.substring(0,userAgent.indexOf('.')); $.browser.version = userAgent; }