Javascript 改变页面样式
时间:2010-09-28 来源:Miler
<link id="cssChange" href="http://www.cnblogs.com/css/s01/s1v9.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
//定入Cookies处理方法
var Ju51Site=new Object();
Ju51Site.Cookie={
set:function(name,value,expires,path,domain){
if(typeof expires=="undefined"){
expires=new Date(new Date().getTime()+10*24*3600*1000);
}
document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"; path=/")+((domain)?";domain="+domain:"");
},
get:function(name){
var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr!=null){
return unescape(arr[2]);
}
return null;
},
clear:function(name,path,domain){
if(this.get(name)){
document.cookie=name+"="+((path)?"; path="+path:"; path=/")+((domain)?"; domain="+domain:"")+";expires=Fri, 02-Jan-1970 00:00:00 GMT";
}
}
};
//设置SKIN
function setSkin(n){
var css = document.getElementById("cssChange");
var cssurl = "http://192.168.0.33:1289/"+n;
css.href=cssurl;
Ju51Site.Cookie.set("Ju51Style",n)
}
//读取上次访问设定的Skin
function LoadSkin(){
var n=Ju51Site.Cookie.get("Ju51Style");
if(n!=null){
setSkin(n);
}
}
</script>
<script language="javascript" type="text/javascript">
//定入Cookies处理方法
var Ju51Site=new Object();
Ju51Site.Cookie={
set:function(name,value,expires,path,domain){
if(typeof expires=="undefined"){
expires=new Date(new Date().getTime()+10*24*3600*1000);
}
document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"; path=/")+((domain)?";domain="+domain:"");
},
get:function(name){
var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr!=null){
return unescape(arr[2]);
}
return null;
},
clear:function(name,path,domain){
if(this.get(name)){
document.cookie=name+"="+((path)?"; path="+path:"; path=/")+((domain)?"; domain="+domain:"")+";expires=Fri, 02-Jan-1970 00:00:00 GMT";
}
}
};
//设置SKIN
function setSkin(n){
var css = document.getElementById("cssChange");
var cssurl = "http://192.168.0.33:1289/"+n;
css.href=cssurl;
Ju51Site.Cookie.set("Ju51Style",n)
}
//读取上次访问设定的Skin
function LoadSkin(){
var n=Ju51Site.Cookie.get("Ju51Style");
if(n!=null){
setSkin(n);
}
}
</script>
相关阅读 更多 +