jQuery 從 1.9 版開始,移除了 $.browser 和 $.browser.version , 取而代之的是 $.support 。
下面是根據navigator.userAgent.toLowerCase()方法請求瀏覽器信息頭判斷瀏覽器類型的方法:
var broswer = {
userCase: navigator.userAgent.toLowerCase(),
isMozilla : function(){
return /firefox/.test(userCase);
},
isWebkit: function(){
return /webkit/.test(userCase);
},
isOpera: function(){
return /opera/.test(userCase);
},
isMsie : function(){
return /msie/.test(userCase);
},
isIe6: function(){
return 'undefined' == typeof(document.body.style.maxHeight);
},
isIE6_8: function(){
return !$.support.leadingWhitespace;
},
isIe7: function(){
return this.isMsie && $.browser.version < 8 ? true : false;
}
}web