This article describes the JS+CSS simple to achieve a Web page skin-changing effect. Share to everyone for your reference, specific as follows:
Here do 3 sets of appearance, using different folders under the same name CSS file, then how to implement JS replacement load it?
The 3 buttons are as follows:
<a id= "skin1" href= "javascript:void (0)" class= "Easyui-linkbutton" onclick= "changecss (' Default ')" > Blue skin </a ><br/><br/>
<a id= "skin2" href= "Javascript:void" (0) "class=" Easyui-linkbutton "onclick=" Changecss (' Gray ') "> Grey skin </a><br/><br/>
<a id=" skin3 "href=" javascript:void (0) "class=" Easyui-linkbutton "onclick=" changecss (' unite ') > Custom Skin </a>
JS Code:
Replace the theme
function Changecss (cssname) {
if (document.getelementsbytagname_r ("link"). Length > 0) {for
( var i = 0; I < Document.getelementsbytagname_r ("link"). Length; i++) {
var ctrllink = document.getelementsbytagname_r ("link") [I];
var cssold = Ctrllink.getattribute ("href");
var cssnew = cssold.replace ("Default", Cssname);
Cssnew = Cssnew.replace ("Gray", cssname);
Cssnew = Cssnew.replace ("unite", Cssname);
Ctrllink.setattribute ("href", cssnew);
}
}
Implementation effect:
I hope this article will help you with JavaScript programming.