js控制网站皮肤
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link id="background" rel="stylesheet" href="css/black.css">
</head>
<body>
<a href="#" onclick="change('orange')">[橙色地带]</a>
<a href="#" onclick="change('green')">[绿色背景]</a>
<a href="#" onclick="change('red')">[灰色空间]</a>
</body>
</html>
js:
function change(type) {
if (type == "orange") {
document.getElementById("background").href = "css/orange.css";
}
else if (type == "green") {
document.getElementById("background").href = "css/green.css";
}
else if (type == "red") {
document.getElementById("background").href = "css/red.css";
}
}
然后再写三个外联css文档,设置相应的background举例:
亲测外联好使,其他没测,请自行测试