检测浏览器版本包括IE11

<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" />
<title>蚂蚁部落</title>
<script type="text/javascript">
var userAgent = navigator.userAgent,   
rMsie = /(msie\s|trident.*rv:)([\w.]+)/,   
rFirefox = /(firefox)\/([\w.]+)/,   
rOpera = /(opera).+version\/([\w.]+)/,   
rChrome = /(chrome)\/([\w.]+)/,   
rSafari = /version\/([\w.]+).*(safari)/;  
var browser;  
var version;  
var ua = userAgent.toLowerCase();  
function uaMatch(ua){  
  var match = rMsie.exec(ua);  
  if(match != null){  
    return { browser : "IE", version : match[2] || "0" };  
  }  
  var match = rFirefox.exec(ua);  
  if (match != null) {  
    return { browser : match[1] || "", version : match[2] || "0" };  
  }  
  var match = rOpera.exec(ua);  
  if (match != null) {  
    return { browser : match[1] || "", version : match[2] || "0" };  
  }  
  var match = rChrome.exec(ua);  
  if (match != null && ua.indexOf("se")==-1&&ua.indexOf("theworld")==-1) {  
    return { browser : match[1] || "", version : match[2] || "0" };  
  }  
  var match = rSafari.exec(ua);  
  if (match != null) {  
    return { browser : match[2] || "", version : match[1] || "0" };  
  }  
  if (match == null) {  
      if ( ua.indexOf( "360" ) >= 0 || ua.indexOf( "360ee" ) >= 0 )
				return { browser : "360", version : "0" }; 
	 else if ( ua.indexOf( "maxthon" ) >= 0 )
				return { browser : "Maxthon", version : "0" }; 
     else if ( ua.indexOf( "se" ) >= 0 )
				return { browser : "SouGou", version : "0" };
     else if ( ua.indexOf( "theworld" ) >= 0 )
				return { browser : "TheWorld", version : "0" }; 
     else  return { browser : "unknown", version : "0" };  
               
  }  
}  
var browserMatch = uaMatch(userAgent.toLowerCase());  
if (browserMatch.browser){  
  browser = browserMatch.browser;  
  version = browserMatch.version;  
}  
document.write(browser+version);          
</script>
</script>
</head>
<body>
 
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值