javascript
<script language="JavaScript" type="text/javascript">
function SetCookie(name,value){
var argv=SetCookie.arguments;
var argc=SetCookie.arguments.length;
var expires=(2<argc)?argv[2]:null;
var path=(3<argc)?argv[3]:null;
var domain=(4<argc)?argv[4]:null;
var secure=(5<argc)?argv[5]:false;
document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}
function GetCookie(Name) {
var search = Name + "=";
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset,end));
}
}
return returnvalue;
}
var thisskin;
thisskin=GetCookie("nowskin");
if(thisskin!="")
skin.href=thisskin;
else
skin.href="cssskin/green.css";
function changecss(url){
if(url!=""){
skin.href=url;
var expdate=new Date();
expdate.setTime(expdate.getTime()+(24*60*60*1000*30));
//expdate=null;
//以下設置COOKIES時間為1年,自己隨便設置該時間..
SetCookie("nowskin",url,expdate,"/",null,false);
}
}
//-->
</script>
HTML
<P>選擇測試換膚效果</P>
<a href="#" onClick="changecss('cssskin/red.css')">紅</a>
<a href="#" onClick="changecss('cssskin/orange.css')">橙</a>
<a href="#" onClick="changecss('cssskin/yellow.css')">黃</a>
<a href="#" onClick="changecss('cssskin/green.css')">綠</a>
<a href="#" onClick="changecss('cssskin/blue.css')">藍</a>
<a href="#" onClick="changecss('cssskin/purple.css')">紫</a>
<select onChange="changecss(this.value)">
<option>選擇樣式</option>
<script language="javascript" type="text/javascript">
var csss=new Array();
csss[0]="cssskin/red.css";
csss[1]="cssskin/orange.css";
csss[2]="cssskin/yellow.css";
csss[3]="cssskin/green.css";
csss[4]="cssskin/blue.css";
csss[5]="cssskin/purple.css";
var i;
for(i=0;i<6;i++)
if(thisskin==csss[i])
document.write("<option value=\""+csss[i]+"\" selected>"+csss[i]+"</option>");
else
document.write("<option value=\""+csss[i]+"\">"+csss[i]+"</option>");
</script>
</select>
效果演示:http://www.qqb4.com/attachments/cssskin/index.html