<html>
<head>
<link rel="stylesheet" type="text/css" id="style1" href="style1.css" />
<script type="text/javascript">
function changeStyle(opt)
{
document.getElementById("style1").href= opt.value + ".css";
}
</script>
</head>
<body>
<input type="radio" name="css" onclick="return changeStyle(this);" value="style1" >Original
<input type="radio" name="css" onclick="return changeStyle(this);" value="style2" >Another
</body>
</html>
<html>
<head>
<link rel="stylesheet" type="text/css" id="style1" href="style1.css" />
<script type="text/javascript">
function changeStyle(opt)
{
document.getElementById("style1").href= opt + ".css";
setCookie("userstyle",opt,365);
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
return "";
}
return "";
}
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function checkColor()
{
userstyle=getCookie('userstyle');
if (userstyle != "")
{
changeStyle(userstyle);
var rad = document.getElementsByTagName("input")
for(var y=0;y<rad.length;y++)
{
if(rad[y].type=="radio" && rad[y].value == userstyle)
rad[y].checked = true;
}
}
}
</script>
</head>
<body onload="checkColor();">
<input type="radio" name="css" onclick="changeStyle(this.value);" value="style1" >Original
<input type="radio" name="css" onclick="changeStyle(this.value);" value="style2" >Another
</body>
</html>
Open in new window