jquery 1.9+ 下 判斷瀏覽器類型總結

http://blog.csdn.net/greenqingqingws/article/details/25043545 原文地址,總結的很好。

1 mozilla

if(/firefox/.test(navigator.userAgent.toLowerCase())){}

 

2 webkit

if(/webkit/.test(navigator.userAgent.toLowerCase())){}

 

3 opera

if(/opera/.test(navigator.userAgent.toLowerCase())){}

 

4 ie

if(/msie/.test(navigator.userAgent.toLowerCase())){}

5 ie6

if ('undefined' == typeof(document.body.style.maxHeight)) {}

6 ie6-8

if (!$.support.leadingWhitespace) {}

7 IE11的检测方

var ua=navigator.userAgent.toLowerCase();
if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
  //浏览器类型
  browserType = "IE";
  //浏览器版本
  browserVersion = ua.match(/msie ([\d.]+)/) != null ? ua.match(/msie ([\d.]+)/)[1] : ua.match(/rv:([\d.]+)/)[1]; 
}
posted @ 2015-01-29 00:18  Zell~Dincht  阅读(142)  评论(0编辑  收藏  举报