zoukankan      html  css  js  c++  java
  • js判定浏览器的种类

    <script type="text/javascript">              
        function userAgent(){                 
         var ua = navigator.userAgent;                  
         ua = ua.toLowerCase();                  
         var match = /(webkit)[ \/]([\w.]+)/.exec(ua) ||                  
         /(opera)(?:.*version)?[ \/]([\w.]+)/.exec(ua) ||                  
         /(msie) ([\w.]+)/.exec(ua) ||                  
         !/compatible/.test(ua) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(ua) ||
         [];      //如果需要获取浏览器版本号:match[2]
         alert(match);
         switch (match[1]) {      
          case "msie":      //ie      
           if (parseInt(match[2]) === 6)    //ie6       
            document.body.innerHTML='IE6 '       
            else if (parseInt(match[2]) === 7)    //ie7
                alert("ie7");       
            else if (parseInt(match[2]) === 8)    //ie8
                alert("ie8"); break;  
            case "webkit":     //safari or chrome
                alert("safari or chrome"); break;      
             case "opera":      //opera
                 alert("opera"); break; 
            case "mozilla":    //Firefox
            alert("Firefox"); break; default: break;
    } 
    }     
            userAgent();   
        </script> 
    
  • 相关阅读:
    分数的表示和运算
    用户管理
    DML,DDL
    索引
    sql语句执行顺序
    伪劣
    序列
    视图
    完整性约束
    ASP.NET MVC学习笔记(二)登陆验证
  • 原文地址:https://www.cnblogs.com/fuge/p/2417918.html
Copyright © 2011-2022 走看看