zoukankan      html  css  js  c++  java
  • js获取浏览器版本

    获取火狐,谷歌,ie,常见浏览器的方法

    function myBrowser(){
    	var userAgent = navigator.userAgent,     
    	rMsie = /(msies|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) {    
    	    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) {    
    	    return { browser : "", version : "0" };    
    	  }    
    	}    
    	var browserMatch = uaMatch(userAgent.toLowerCase());    
    	if (browserMatch.browser){    
    	  browser = browserMatch.browser;    
    	  version = browserMatch.version;    
    	}    
    	var x = browser+parseInt(version);
    	console.log(x);
    	return x
    }
    
    
  • 相关阅读:
    Redis-其他命令
    Redis-发布与订阅
    C#使用命令编译代码
    Redis有序集合操作
    Redis散列操作
    设置ul水平居中
    Redis集合操作
    Redis列表操作
    java连SQLServer失败 java.lang.ClassNotFoundException:以及 javax.xml.bind.JAXBException
    SQLServer 用法简例
  • 原文地址:https://www.cnblogs.com/yangwang12345/p/7729368.html
Copyright © 2011-2022 走看看