/* ======= Save the following code as: skincss. js ========= */
Function getcookie (sname)
{
VaR acookie = Document. Cookie. Split (";");
For (VAR I = 0; I <acookie. length; I ++)
{
VaR acrumb = acookie [I]. Split ("= ");
If (sname = acrumb [0])
{
Return acrumb [1];
}
}
Return NULL;
}
Function setcookie (name, value, time, domain)
{
VaR expdate = new date ();
VaR expires = time;
If (expires! = NULL ){
Expdate. settime (expdate. gettime () + (expires * 1000 ));
Expd = "expires =" + expdate. togmtstring () + ";";
} Else
Expd = "";
If (domain)
{
Domain = "Domain =" + domain + "; Path = /;";
}
Document. Cookie = Name + "=" + escape (value) + ";" + expd + domain;
}
VaR cookietag = "crystal_skin ";
VaR vskin = getcookie (cookietag );
Function setskincolor (vskinnum)
{
Setcookie (cookietag, vskinnum, 60*60*24*30, "cnwest.com ");
Document. getelementbyid ("skincss"). href = "CSS/" + vskinnum + "/style.css ";
}
If (vskin & vskin! = "Style ")
{
Document. getelementbyid ("skincss"). href = "CSS/" + vskin + "/style.css ";
}
/* ======= Save the following code as: index.html ======== */
<! 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> CSS skin replacement </title>
<Style type = "text/CSS">
. Skincolorblue,. skincolorred,. skincolorpurple {font-size: 10px; cursor: pointer ;}
. Skincolorblue {background-color: #77c9f8; color: #77c9f8 ;}
. Skincolorred {background-color: # f67272; color: # f67272 ;}
. Skincolorpurple {background-color: # f675dc; color: # f675dc ;}
</Style>
<Link id = "skincss" href = "CSS/style.css" rel = "stylesheet" type = "text/CSS"/>
<Script. type = "text/JavaScript" src = "JS/skincss. js"> </SCRIPT>
</Head>
<Body>
<SPAN class = "skincolorblue" onclick = "setskincolor ('blue');" Title = "Crystal Blue"> blue </span>
<SPAN class = "skincolorred" onclick = "setskincolor ('red');" Title = "Rose Red"> Red </span>
<SPAN class = "skincolorpurple" onclick = "setskincolor ('purple ');" Title = "aristocrat purple"> purple </span>
</Body>
</Html>
/* ======= Save the following code as: style.css ========= */
The blue, red, and purple directories are created under the directories on the page and placed in the CSS tables you need. The directory structure is as follows:
1. CSS/blue/style.css
CSS style: body {background-color: #77c9f8 ;}
2. CSS/red/style.css
CSS style: body {background-color: # f67272 ;}
3. CSS/purple/style.css
CSS style: body {background-color: # f675dc ;}
4. CSS/style.css
CSS style: body {background-color: # ffccff ;}
Note: setcookie (cookietag, vskinnum, 60*60*24*30, "cnwest.com ");
Used to record the cookie. You can change cnwest.com to your domain name or leave it blank.
For example, setcookie (cookietag, vskinnum, 60*60*24*30 ,"");