with persistance
Code:
<!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" xml:lang="en" lang="en">
<head>
<title></title>
<link rel="stylesheet" title="default" href="theam1.css" type="text/css" />
<style type="text/css">
/*<![CDATA[*/
.sheet1 {
width:200px;height:200px;background-Color:red;
}
/*]]>*/
</style>
</head>
<body>
<div class="sheet1" ></div>
<select id="s1" onchange="SwapSheet('default',this.value);" >
<option value="theam1.css" >theam1.css</option>
<option value="theam2.css" >theam2.css</option>
<option value="theam3.css" >theam3.css</option>
</select>
<script type="text/javascript">
/*<![CDATA[*/
function SwapSheet(t,ns,days){
var s=document.getElementsByTagName('LINK'),os,z0=0;;
for (var os,z0=0;z0<s.length;z0++){
if (s[z0].title==t){
os=s[z0];
break;
}
}
if (os&&typeof(ns)=='string'){
var s=os.cloneNode(false);
s.href=ns;
os.parentNode.appendChild(s);
os.parentNode.removeChild(os);
days!=-1?document.cookie=t+'='+ns+(typeof(days)=='number'?';expires='+(new Date(new Date().getTime()+days*86400000).toGMTString())+';path/;':';'):null;
}
}
function cookie(t,days,id){
var re=new RegExp(t+'=[^;]+','i'),ns,s=document.getElementById(id),o,z0=0;
ns=document.cookie.match(re)?document.cookie.match(re)[0].split("=")[1]:null;
if (ns){
SwapSheet(t,ns,days);
if (s){
o=s.options||[];
for (;z0<o.length;z0++){
if (o[z0].value==ns){
s.selectedIndex=z0;
break;
}
}
}
}
}
//parameter 0 = the style sheet title.
//parameter 1 = the number of days to restore the last HREF.
//parameter 2 = the unique ID name is the select element.
cookie('default',1,'s1')
/*]]>*/
</script>
</body>
</html>
Bookmarks