//其中部分代码可以优化 暂定一版本
var Obj = document.getElementById("btn");
Obj.onclick = function (){
var sx = getCookie("shuaxin");
if (sx == "jia") {
setCookie("shuaxin","zhen");
} else{
setCookie("shuaxin","jia");
}
var sx = getCookie("shuaxin");
if (sx == "zhen"){
Obj.value = "停止自动刷新";
setTimeout("myrefresh()",20000);
}
if (sx == "jia"){
Obj.value = "开启自动刷新";
}
}
var username=document.cookie.split(";")[0].split("=")[1];
function setCookie(name,value)
{
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
window.οnlοad=function(){
var sx = getCookie("shuaxin");
if (sx == "zhen"){
Obj.value = "停止自动刷新";
setTimeout("myrefresh()",20000);
} else {
Obj.value = "开启自动刷新";
}
}
function myrefresh(){
window.location.reload();
}