Tips and tricks
Javascript Detect any Browser and Browser Version
Since jQuery 1.9.0 removed the jQuery.browser functionality, I compiled some useful functions to replicate that functionality.
[raw]
function is_ie(){ if (navigator.appVersion.indexOf("MSIE") != -1){ return true; }; return false; }; function is_firefox(){ if (navigator.userAgent.indexOf("Firefox") != -1){ return true; }; return false; }; function is_opera(){ if (navigator.userAgent.indexOf("Opera") != -1){ return true; }; return false; }; function is_chrome(){ return navigator.userAgent.toLowerCase().indexOf('chrome') > -1; }; function is_safari(){ return navigator.userAgent.toLowerCase().indexOf('safari') > -1; }; function version_ie(){ return parseFloat(navigator.appVersion.split("MSIE")[1]); }; function version_firefox(){ if (/Firefox[/s](d+.d+)/.test(navigator.userAgent)){ var aversion=new Number(RegExp.$1); return(aversion); }; }; function version_opera(){ if (/Opera[/s](d+.d+)/.test(navigator.userAgent)){ var aversion=new Number(RegExp.$1); return(aversion); }; }; function is_ios() { return ((navigator.platform.indexOf("iPhone") != -1) || (navigator.platform.indexOf("iPod") != -1) || (navigator.platform.indexOf("iPad") != -1 || (navigator.platform.indexOf("Android") != -1)) ); } function is_android() { //return true; return (navigator.platform.indexOf("Android") != -1); }
[/raw]