zoukankan      html  css  js  c++  java
  • JS如何判断IE和火狐与Chrome浏览器

    JS如何判断IE和火狐与Chrome浏览器  

    2013-08-16 21:01:17|  分类: 技术 |举报 |字号 订阅

     
    var isIE=navigator.userAgent.toUpperCase().indexOf("MSIE")?true:false; 
    类似的可以写
    var isFirefox=navigator.userAgent.toUpperCase().indexOf("Firefox")?true:false;
    var isChrome = window.navigator.userAgent.indexOf("Chrome") !== -1
    之类的东西

    大概就这样
    <script type="text/javascript">
    var isIE=navigator.userAgent.toUpperCase().indexOf("MSIE")==-1?false:true;
    if(isIE) document.getElementById("abc").style.display="";
    </script>

    实例 如果是IE显示DIV否则隐藏
    <body>
    <div id=abc style="display:none;">
    11111111111
    </div>
    <script type="text/javascript">
    var isIE=navigator.userAgent.toUpperCase().indexOf("MSIE")==-1?false:true;
    if(isIE) document.getElementById("abc").style.display="";
    </script>
    </body>
  • 相关阅读:
    Xcode代码块快捷输入
    Git常用命令
    vim
    MACOX中apache配置
    IOS中实现动画的几种方式
    Swift与OC混合编译
    网络图像加载
    我对互联网的理解
    运行时
    自动布局使用
  • 原文地址:https://www.cnblogs.com/dingyuanxin/p/3977775.html
Copyright © 2011-2022 走看看