I always use this code to check the user agent and it's version:
navigator.sayWho= (function(){
var ua= navigator.userAgent, tem,
M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if(/trident/i.test(M[1])){
tem= /\brv[ :]+(\d+)/g.exec(ua) || [];
navigator.isIE = true;
return 'IE '+(tem[1] || '');
}
navigator.isIE = false;
if(M[1]=== 'Chrome'){
tem= ua.match(/\bOPR\/(\d+)/)
if(tem!= null) return 'Opera '+tem[1];
}
M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
return M.join(' ');
})();
It will tell you the name and the version of any user agent. Unfortunately, I don't know the original source of this code anymore.
Note that this code also works without jQuery.
However, you should try to avoid such code and use feature detection instead.
navigator.userAgent.toLowerCase().split('/').pop()returns"34.0"I wouldn't use this in production for all browsers without testing