JS自动刷新 有个复选框,如果选中复选框,就自动刷新,如果不想自动刷新了,就去掉复选框 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>var tid, cookie;String.prototype.Trim = function() { return this.replace(/^\s+/g,"").replace(/\s+$/g,""); } function JSCookie() { this.GetCookie = function(key) { var cookie = document.cookie; var cookieArray = cookie.split(';'); var getvalue = ""; for(var i = 0;i<cookieArray.length;i++) { if(cookieArray[i].Trim().substr(0,key.length) == key) { getvalue = cookieArray[i].Trim().substr(key.length + 1); break; } } return getvalue; }; this.GetChild = function(cookiekey,childkey) { var child = this.GetCookie(cookiekey); var childs = child.split('&'); var getvalue = ""; for(var i = 0;i < childs.length;i++) { if(childs[i].Trim().substr(0,childkey.length) == childkey) { getvalue = childs[i].Trim().substr(childkey.length + 1); break; } } return getvalue; }; this.SetCookie = function(key,value,expire,domain,path) { var cookie = ""; if(key != null && value != null) cookie += key + "=" + value + ";"; if(expire != null) cookie += "expires=" + expire.toGMTString() + ";"; if(domain != null) cookie += "domain=" + domain + ";"; if(path != null) cookie += "path=" + path + ";"; document.cookie = cookie; }; this.Expire = function(key) { expire_time = new Date(); expire_time.setFullYear(expire_time.getFullYear() - 1); var cookie = " " + key + "=e;expires=" + expire_time + ";" document.cookie = cookie; }}function doit(){ if(tid!=null){clearTimeout(tid);tid=null} var ck = document.getElementById("ck") if(ck.checked){ cookie.SetCookie("ck","1") location.reload() } else{ cookie.SetCookie("ck","0") tid = setTimeout("doit()", 2000) }}window.onload=function(){ cookie = new JSCookie(); var ck = document.getElementById("ck") if(cookie.GetCookie("ck")=="1") ck.checked=true; tid = setTimeout("doit()", 2000)}</script><input type="checkbox" id="ck"> 写个简单滴L@_@K<!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> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <input type="checkbox" id="cbxRefresh" />自动刷新 <script type="text/javascript">document.write("<br />", new Date());function refreshWin() { window.location.href = window.location.href;}var refresh = document.getElementById('cbxRefresh');// 刷新间隔 1000 毫秒。var refreshInterval = 1000;refresh.onclick = function() { if (refresh.checked) { this.TimerID = window.setTimeout(refreshWin, refreshInterval); document.cookie = "isRefresh=true"; } else { window.clearTimeout(this.TimeoutID); document.cookie = "isRefresh=false"; }}document.body.onload = function() { if(document.cookie.indexOf("isRefresh=true") > -1) { refresh.click(); }} </script> </BODY></HTML> ext 如何判断一个按钮是否已被按下 变为灰色? 有没有免费的JS压缩混淆软件? 定时问题 如何使用javascript获得XML文档内容 这个URL应该怎么写? 请教Jquery的on函数用法 为什么我隐藏table中某一行后(display:none),其表格的中的单元格位置都乱了? 请问Findobj怎么用,它的参数是什么?急!!! 只能输入数字,/\D/是什么意思啊? 求一个js回调函数的写法(非常紧急在线等) 在js中如何保存实体类对象 为什么我用js向网页输出一个iframe 在src中连接一个swf文件 但是在IE6下总是提示文件下载呢?
<script>
var tid, cookie;
String.prototype.Trim = function()
{
return this.replace(/^\s+/g,"").replace(/\s+$/g,"");
}
function JSCookie()
{
this.GetCookie = function(key)
{
var cookie = document.cookie;
var cookieArray = cookie.split(';');
var getvalue = "";
for(var i = 0;i<cookieArray.length;i++)
{
if(cookieArray[i].Trim().substr(0,key.length) == key)
{
getvalue = cookieArray[i].Trim().substr(key.length + 1);
break;
}
} return getvalue;
};
this.GetChild = function(cookiekey,childkey)
{
var child = this.GetCookie(cookiekey);
var childs = child.split('&');
var getvalue = "";
for(var i = 0;i < childs.length;i++)
{
if(childs[i].Trim().substr(0,childkey.length) == childkey)
{
getvalue = childs[i].Trim().substr(childkey.length + 1);
break;
}
}
return getvalue;
};
this.SetCookie = function(key,value,expire,domain,path)
{
var cookie = "";
if(key != null && value != null)
cookie += key + "=" + value + ";";
if(expire != null)
cookie += "expires=" + expire.toGMTString() + ";";
if(domain != null)
cookie += "domain=" + domain + ";";
if(path != null)
cookie += "path=" + path + ";";
document.cookie = cookie;
};
this.Expire = function(key)
{
expire_time = new Date();
expire_time.setFullYear(expire_time.getFullYear() - 1);
var cookie = " " + key + "=e;expires=" + expire_time + ";"
document.cookie = cookie;
}
}function doit(){
if(tid!=null){clearTimeout(tid);tid=null}
var ck = document.getElementById("ck")
if(ck.checked){
cookie.SetCookie("ck","1")
location.reload()
}
else{
cookie.SetCookie("ck","0")
tid = setTimeout("doit()", 2000)
}
}
window.onload=function(){
cookie = new JSCookie();
var ck = document.getElementById("ck")
if(cookie.GetCookie("ck")=="1") ck.checked=true;
tid = setTimeout("doit()", 2000)
}
</script>
<input type="checkbox" id="ck">
<!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>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD> <BODY>
<input type="checkbox" id="cbxRefresh" />自动刷新
<script type="text/javascript">
document.write("<br />", new Date());function refreshWin() {
window.location.href = window.location.href;
}var refresh = document.getElementById('cbxRefresh');
// 刷新间隔 1000 毫秒。
var refreshInterval = 1000;
refresh.onclick = function() {
if (refresh.checked) {
this.TimerID = window.setTimeout(refreshWin, refreshInterval);
document.cookie = "isRefresh=true";
}
else {
window.clearTimeout(this.TimeoutID);
document.cookie = "isRefresh=false";
}
}document.body.onload = function() {
if(document.cookie.indexOf("isRefresh=true") > -1) {
refresh.click();
}
}
</script>
</BODY>
</HTML>