zoukankan      html  css  js  c++  java
  • 如何判断浏览器类型然后让它读取指定的CSS

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    if (window.navigator.userAgent.indexOf("MSIE")>=1)
    {
    //如果浏览器为IE
    setActiveStyleSheet("default.css");
    }else{
    if (window.navigator.userAgent.indexOf("Firefox")>=1)
    {
    //如果浏览器为Firefox
    setActiveStyleSheet("default2.css");
    }else{
    //如果浏览器为其他
    setActiveStyleSheet("newsky.css");
    }
    }

    function setActiveStyleSheet(title){
      document.getElementsByTagName("link")[0].href="style/"+title;
    }
    //--></SCRIPT>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <link href="" rel="stylesheet" type="text/css" id="link"/>

    <SCRIPT>
    function oo(obj){
            return typeof(obj)=="string"?document.getElementById(obj):obj
    }

     if (window.navigator.userAgent.indexOf("MSIE")>=1){
            oo("link").href='1.css';
            alert("当前浏览器为IE,css文件为"+oo("link").href);
    }else{
            if (window.navigator.userAgent.indexOf("Firefox")>=1){
                  oo("link").href='2.css';
                  alert("当前浏览器为Firefox,css文件为"+oo("link").href);
            }else{
                  oo("link").href='3.css';
                  alert("当前浏览器为其他,css文件为"+oo("link").href);
            }
     }

    </SCRIPT>
    </head>
    <body>

    </body>
    </html>

  • 相关阅读:
    注册算法入门
    call传参之通过堆栈
    winhex注意
    输入字符串长度
    integer promotion
    网页flash兼容浏览器代码
    逆向工程——注册篇
    esp定律的一点说明
    base64
    意外
  • 原文地址:https://www.cnblogs.com/visi_zhangyang/p/1963749.html
Copyright © 2011-2022 走看看