- 昵 称: (必填)
- QQ 号: (必填)
- 评 论: (必填5-250字)
- 验证码: (必填)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link id="cssfile" href="style2.css" rel="stylesheet" type="text/css" />
</head>
<script>
// *** Cookies ***
function setCookie(name,value)
{
var Days = 30;
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)
{
var arr,reg=new RegExp("(^&line; )"+name+"=([^;]*)(;&line;)");
if(arr=document.cookie.match(reg)) return unescape(arr[2]);
else return null;
}
function changeStyle(name){
setCookie("cssStyle",name);
css=document.getElementById("cssfile");
css.href=name+".css";
}
var varcss = getCookie("cssStyle");
changeStyle(varcss);
</script>
<body>
<div >
<a onclick="changeStyle('style1');" href="#" id="d1" >aaa</a>
<a onclick="changeStyle('style2');" href="#" id="d2" >bbb</a>
</div>
</body>
</html>
样式1
body {
background-color: #f00;
}
#d1{ font-size: 28px;}
样式2
body {
background-color: #330099;
}
#d2{ font-size: 18px;}