根据不同的按钮来转换网站的肤色。详细代码:
<html>
<cabeça>
<title>网页换肤</title>
<link id="myCss" href="orange.css" rel="stylesheet">
<roteiro>
função writeCookie(csspath){
var hoje=nova data();
var expira=nova data();
expira.setTime(hoje.getTime()+1000*60*60*24*30);
var str="cssPath="+csspath+";expires="+expires.toGMTString()+";";
documento.cookie=str;
}
function readCookie(nomedocookie){
var search=nomedocookie+"=";
if(document.cookie.length>0){
deslocamento=document.cookie.indexOf(pesquisar);
if(deslocamento!=-1){
deslocamento+=pesquisa.comprimento;
end=document.cookie.indexOf(";",offset);
se(fim==-1){
end=document.cookie.length;
retornar unescape(document.cookie.substring(offset,end));
}
}
}
}
mudança de função(tipo){
if(type=="laranja"){
document.getElementById("myCss").href="orange.css";
escrevaCookie(laranja.css);
}
if(type=="cinza"){
document.getElementById("myCss").href="gray.css";
writeCookie(cinza.css);
}
}
</script>
</head>
<corpo>
<form action="">
<tabela alinhar="centro">
<tr>
<td align="center"><a href="#" onClick="change('orange')">【橘色经典】</a></td>
<td align="center"><a href="#" onClick="change('gray')">【灰色畅想】</a></td>
</tr>
<tr>
<td>用户名:</td>
<td><input type="text" name="nome" /></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="pwd" /></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="password" name="pwd1" /></td>
</tr>
<tr>
<td>性别:</td>
<td>
<input type="radio" name="sex" value="m" />男
<input type="radio" name="sex" value="f" />女
</td>
</tr>
<tr>
<td>年龄:</td>
<td><input type="text" name="idade" /></td>
</tr>
<tr>
<td><input class="botton1" type="submit" value="注册" /></td>
<td><input class="botton1" type="button" value="重置" /></td>
</tr>
</tabela>
</form>
</body>
</head>
1、默认的颜色为橘色
2、当单击“灰色”的时候,网页风格变为“灰色”
3、当最后点击“橘色”的时候,网页再次变为原色
4、每一次重新打开网页的时候,网页都会还原为橘色的。