zoukankan      html  css  js  c++  java
  • JS获取当前浏览器的类型

    if(navigator.userAgent.indexOf("MSIE")>0)   为ie浏览器。

    navigator.appName.indexOf("Microsoft") != -1  为ie浏览器。

    navigator.userAgent.indexOf("MSIE 6.0")>0  判断是否为ie6

    navigator.appVersion.match(/6./i)=="6."  判断是否为ie6

     

    JS获取浏览器信息
            浏览器代码名称:navigator.appCodeName
            浏览器名称:navigator.appName
            浏览器版本号:navigator.appVersion
            对Java的支持:navigator.javaEnabled()
            MIME类型(数组):navigator.mimeTypes
            系统平台:navigator.platform
            插件(数组):navigator.plugins
            用户代理:navigator.userAgent

     

    DEMO:
    Js代码 
    <script language="JavaScript">  
        <!--  
    function getOs()  
    {  
        var OsObject = "";  
       if(navigator.userAgent.indexOf("MSIE")>0) {  
            return "MSIE";  
       }  
       if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){  
            return "Firefox";  
       }  
       if(isSafari=navigator.userAgent.indexOf("Safari")>0) {  
            return "Safari";  
       }   
       if(isCamino=navigator.userAgent.indexOf("Camino")>0){  
            return "Camino";  
       }  
       if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){  
            return "Gecko";  
       }  
        
    }  
     alert("您的浏览器类型为:"+getOs());  
        -->  
    </script> 

  • 相关阅读:
    设计模式命令模式(Command)
    设计模式责任链模式(COR)
    设计模式备忘录模式(Memento)
    设计模式中介者模式(Mediator)
    设计模式策略模式(Strategy)
    设计模式解释器模式(Interpreter)
    设计模式迭代器模式(Iterator)
    设计模式状态模式(State)
    Ext终于开始收费了
    设计模式观察者模式(Observer)
  • 原文地址:https://www.cnblogs.com/wqing/p/2636626.html
Copyright © 2011-2022 走看看