瀏覽器判斷 —— jQuery 1.9不支持$.browser 判斷瀏覽器類型和版本

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

相關文章
相關標籤/搜索