JS网页换肤

所谓网页换肤,就是换一种不同的样式

当然也必须结合css+js操作来完成

bg1.css 

body {background-color:black;}
bg2.css 

body {background-color:red;}
 

<!
DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <link id="linkcss" href="css/bg1.css" rel="stylesheet" type="text/css"/> </head> <body> <input type="button" value="皮肤1" id="btnStyle1" /> <input type="button" value="皮肤2" id="btnStyle2" /> </body> </html>

如果要换肤只动态的改变link 的 href就好了

 window.onload=function(){
            document.getElementById('btnStyle1').onclick=function(){
                document.getElementById('link1').href='css1.css'; 
            }
            document.getElementById('btnStyle2').onclick=function(){
                document.getElementById('link1').href='css2.css'; 
            }
          
        }

 

posted @ 2014-04-01 15:32  KyrieYang  阅读(253)  评论(0编辑  收藏  举报