zoukankan      html  css  js  c++  java
  • javascript判断IE浏览器的版本

    <!--IE浏览器兼容-->
    <script language="javascript">
    function ie(){
    var isIE=!!window.ActiveXObject;
    var isIE6=isIE&&!window.XMLHttpRequest;
    var isIE8=isIE&&!!document.documentMode;
    var isIE7=isIE&&!isIE6&&!isIE8;
    if (isIE)
    {
       if (isIE6){
       var style = document.createElement('link');
       style.href = '/static/skins/ie7/skinIE6.css';
       style.rel = 'stylesheet';
      style.type = 'text/css';
      document.getElementsByTagName('HEAD').item(0).appendChild(style); 
      alert("ie6");
       }
     else if (isIE8)
       {
       var style = document.createElement('link');
       style.href = '/static/skins/ie7/skinIE7.css';
       style.rel = 'stylesheet';
     style.type = 'text/css';
     document.getElementsByTagName('HEAD').item(0).appendChild(style); 
      alert("ie8");
        }
    else if (isIE7)
       {
        var style = document.createElement('link');
       style.href = '/static/skins/ie7/skinIE7.css';
       style.rel = 'stylesheet';
     style.type = 'text/css';
     document.getElementsByTagName('HEAD').item(0).appendChild(style); 
      alert("ie7");
      }
     }

    }

    //第一次页面的加载时候调用事件
    if (window.addEventListener)
        {
            window.addEventListener("load", ie, false);
        }
     else if (window.attachEvent)
     {
            window.attachEvent("onload", ie);
        }
    else{
            window.onload=ie;
      }
    </script>
    <!--结束-->

  • 相关阅读:
    总结前端笔面试遇到的问题——HTML部分
    js中的克隆方法
    js操作cookie
    JS中4种常见的内存泄漏
    html、css、js三者的加载顺序
    js中object定义的几种方法
    关于settimeout的面试题
    css各种居中解决方法
    JS实现继承的几种方式
    将博客搬至CSDN
  • 原文地址:https://www.cnblogs.com/iloveyoucc/p/2666576.html
Copyright © 2011-2022 走看看