日期:2014-05-16  浏览次数:20771 次

js引用css文件
<html>
  <head>
     <title>js引用css样式</title>
     <script type="text/javascript">
        function create_css(){
          if(document.createStyleSheet){//IE
             document.createStyleSheet("style.css",1);
         }
         else{//FF
             var my_link = document.createElement("link");
             my_link.setAttribute("type","text/css");
             my_link.setAttribute("rel","stylesheet");
             my_link.setAttribute("href","style.css");
             document.getElementsByTagName("head")[0].appendChild(my_link);
         }
        }
        create_css();//document.createStyleSheet("style.css");
     </script>
  </head>
  <body>
    <div id="div"></div>
  </body>
</html>