代码:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd”>
<!– saved from url=(0036)http://radio.fc510.com/code/chgskin/ –>
<HTML xmlns=”http://www.w3.org/1999/xhtml”><HEAD><TITLE>换肤测试程序-龍哥博客</TITLE>
<META http-equiv=Content-Type content=”text/html; charset=gb2312″>
<STYLE type=text/css>.themes {
BORDER-RIGHT: #000 1px solid; BORDER-TOP: #000 1px solid; BORDER-LEFT: #000 1px solid; BORDER-BOTTOM: #000 1px solid
}
</STYLE>
<SCRIPT language=javascript type=text/javascript>
<!–
var arrCSS=[
["<img src='http://www.52blogger.com/yczp/images/ocean.gif' width='16' height='8' class='themes' alt='Ocean'>","http://www.52blogger.com/yczp/css/ocean.css"],
["<img src='http://www.52blogger.com/yczp/images/tangerine.gif' width='16' height='8' class='themes' alt='Tangerine'>","http://www.52blogger.com/yczp/css/tangerine.css"],
["<img src='http://www.52blogger.com/yczp/images/violet.gif' width='16' height='8' class='themes' alt='Violet'>","http://www.52blogger.com/yczp/css/violet.css"],
["<img src='http://www.52blogger.com/yczp/images/oyster.gif' width='16' height='8' class='themes' alt='Oyster'>","http://www.52blogger.com/yczp/css/oyster.css"],
["<img src='http://www.52blogger.com/yczp/images/grass.gif' width='16' height='8' class='themes' alt='Grass'>","http://www.52blogger.com/yczp/css/grass.css"],
“”
];
// *** function to replace href=”#” ***
function v(){
return;
}
// *** Cookies ***
function writeCookie(name, value) {
exp = new Date();
exp.setTime(exp.getTime() + (86400 * 1000 * 30));
document.cookie = name + “=” + escape(value) + “; expires=” + exp.toGMTString() + “; path=/”;
}
function readCookie(name) {
var search;
search = name + “=”;
offset = document.cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = document.cookie.indexOf(“;”, offset);
if (end == -1){
end = document.cookie.length;
}
return unescape(document.cookie.substring(offset, end));
}else{
return “”;
}
}
////////////////////////////////////
// StyleSheet
////////////////////////////////////
function writeCSS(){
for(var i=0;i<arrCSS.length;i++){
document.write(‘<link title=”css’+i+’” href=”‘+arrCSS[i][1]+’” rel=”stylesheet” disabled=”true” type=”text/css” />’);
}
setStyleSheet(readCookie(“stylesheet”));
}
function writeCSSLinks(){
for(var i=0;i<arrCSS.length-1;i++){
if(i>0) document.write(‘ ‘);
document.write(‘<a href=”javascript:v()” onclick=”setStyleSheet(\’css’+i+’\')”>’+arrCSS[i][0]+’</a>’);
}
}
function setStyleSheet(strCSS){
var objs=document.getElementsByTagName(“link”);
var intFound=0;
for(var i=0;i<objs.length;i++){
if(objs[i].type.indexOf(“css”)>-1&&objs[i].title){
objs[i].disabled = true;
if(objs[i].title==strCSS) intFound=i;
}
}
objs[intFound].disabled = false;
writeCookie(“stylesheet”,objs[intFound].title);
}
writeCSS();
setStyleSheet(readCookie(“stylesheet”));
// 隐藏显示换肤框
function ShowHideDiv(init) {
if(document.getElementById(“Sright”).style.display == “block”){
document.getElementById(“Sright”).style.display = “none”;
}
else{
document.getElementById(“Sright”).style.display = “block”;
}
}
//–>
</SCRIPT>
<META content=”MSHTML 6.00.2900.3132″ name=GENERATOR></HEAD>
<BODY>
<DIV></DIV>
<DIV></DIV>
<DIV>
<span id=page_options onclick=ShowHideDiv()>
皮肤设置选项
<span id=Sright>
<SCRIPT type=”text/javascript”>writeCSSLinks();</SCRIPT>
</span>
</span></DIV>
<DIV></DIV>
<DIV>
<DIV>
<DIV></DIV></DIV>
<DIV>
<DIV>
<h3>思考</h3>
<p>
程序通过JS实现调用不同的CSS文件,并写入COOKIE防止页面刷新.<br/><br/>
但是这些CSS文件基本一致,只是颜色代码不同而已!<br/><br/>
能否用一个CSS文件通过传一个颜色的参数,来显示不同的颜色?<br/><br/>
有兴趣爱好的朋友,欢迎来此龍哥博客讨论交流,投稿<br/><br/>
讨论交流地址:
<a href=”http://www.52blogger.com/%E4%BA%92%E5%8A%A8%E4%BA%A4%E6%B5%81″ target=”_bank”>http://www.52blogger.com/%E4%BA%92%E5%8A%A8%E4%BA%A4%E6%B5%81</a><br/><br/>
申请投稿地址:<a href=”http://www.52blogger.com/wp-login.php?action=register” target=”_bank”>http://www.52blogger.com/wp-login.php?action=register</a><br/><br/>
龍哥邮箱:<a href=”mailto:bingxingke2@163.com”>bingxingke2@163.com</a>
</p>
<p>
更多特效来自龍哥博客<a href=”http://www.52blogger.com” target=”_bank”>http://www.52blogger.com</a>
</p>
</DIV>
<DIV></DIV></DIV>
<DIV>
<DIV></DIV></DIV>
<DIV></DIV></DIV>
<DIV></DIV>
<DIV>
</DIV>
</BODY></HTML>
演示地址:http://www.52blogger.com/yczp/longblog_hf.html
下载地址:http://u.115.com/file/t465f2399a