多浏览器的选择

来源:互联网 发布:mysql命令行导入excel 编辑:程序博客网 时间:2024/05/15 02:18


获得当前浏览器型号 名字  

        //browerName fuction knows which brower is using now.


          var browerName = function() {
            var Sys = {};
            var ua = navigator.userAgent.toLowerCase();
            var s;
            (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1]: (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] : (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] : (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] : (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;

            if (Sys.ie != null) {
              return ("IE:" + Sys.ie); //IE browser and version number
            }
            if (Sys.firefox != null) {
              return ("firefox:" + Sys.firefox); //firefox browser and version number
              scope.firefox = true;
            }
            if (Sys.chrome != null) {
              return ("chrome:" + Sys.chrome); // chrome browser and version number
              scope.chrome = true;
            }
            if (Sys.opera != null) {
              return ("opera:" + Sys.opera); //opera browser and version number
            }
            if (Sys.safari != null) {
              return ("safari:" + Sys.safari); //safari browser and version number
            }
          };


          console.log(browerName());

0 0
原创粉丝点击