動態載入CSS

來源:互聯網
上載者:User
<script type="text/javascript">
            function addStyle(stylePath) {
                var container = document.getElementsByTagName("head")[0];
                var addStyle = document.createElement("link");
                addStyle.rel = "stylesheet";
                addStyle.type = "text/css";
                addStyle.media = "screen";
                addStyle.href = stylePath;
                container.appendChild(addStyle);
            }
            addStyle('http://files.cnblogs.com/wintys/dynamic.css');
</script>

 

 

樣本頁面(此頁面CSS是動態載入的):http://www.cnblogs.com/wintys/archive/2013/03/21/ui_windows7_fieldset.html

樣本頁面動態載入的CSS檔案是這個:http://files.cnblogs.com/wintys/dynamic.css

 

【來源】動態添加css http://www.cnblogs.com/niuniu/archive/2010/05/03/1726303.html
【參考】CSS檔案動態載入 http://www.cnblogs.com/chyingp/archive/2013/03/01/load_css.html

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.