网页自动定时刷新的代码-html定时刷新代码-asp时刷新代码
2009-06-29 20:48
477 查看
1:
加到body中间,这里是3:00为三分钟,可以自定
2:
Ajax实现定时刷新,获取后台数据
首先介绍个网站上面的东西值得参考比如XML DOM,HTML Dom,javascript.在开发Ajax应用的时候,随时可以找到你需要的内容.
Now(),开始我们的主题:
这里我们用Access作为数据库,建个数据库名称为user.mdb和update.html,update.asp放同一目录,再建表,如下
ok,非常简单,为了演示吗 呵呵~!!~!
update.html页面,不用解释太多,里面有注释
3:
我认为在ASP中最好的办法是用编程实现定时刷新Cache,也就是说给Application中储存的设一个过期时间。当然,在ASP中Application对象没有这样一个ExpireTime属性。这需要用程序实现。
Code
ASP:default.asp
ASP:getcache.asp
上面是一个最简单的例子。
4:
最好的自动刷新代码
5:
在<head></head>加入以下代码
<meta http-equiv=refresh content="2; url=test.asp">
content 是间秒数
<mce:script type="text/javascript"><!-- var limit="3:00" if (document.images){ var parselimit=limit.split(":") parselimit=parselimit[0]*60+parselimit[1]*1 } function beginrefresh(){ if (!document.images) return if (parselimit==1) window.location.reload() else{ parselimit-=1 curmin=Math.floor(parselimit/60) cursec=parselimit%60 if (curmin!=0) curtime=curmin+" min "+cursec+" sec " else curtime=cursec+" sec " window.status=curtime setTimeout("beginrefresh()",1000) } } window.onload=beginrefresh // --></mce:script>
加到body中间,这里是3:00为三分钟,可以自定
2:
Ajax实现定时刷新,获取后台数据
首先介绍个网站上面的东西值得参考比如XML DOM,HTML Dom,javascript.在开发Ajax应用的时候,随时可以找到你需要的内容.
Now(),开始我们的主题:
这里我们用Access作为数据库,建个数据库名称为user.mdb和update.html,update.asp放同一目录,再建表,如下
ok,非常简单,为了演示吗 呵呵~!!~!
update.html页面,不用解释太多,里面有注释
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <title>Untitled Document</title> <!--begin stylesheet--> <mce:style type="text/css"><!-- table.news_table ...{ border: 1px; border-style: dotted; border-color: #00CC99; border-top: 0; font-size: 14px; background: #FFFFFF; color: #669999; } table.news_table thead tr ...{ color: #FFFFFF; background: #0099CC; border-bottom: 2px solid #FF0000; padding: 2px 10px; } table.news_table tbody tr ...{ padding: 2px 10px; } --></mce:style><style type="text/css" mce_bogus="1">table.news_table ...{ border: 1px; border-style: dotted; border-color: #00CC99; border-top: 0; font-size: 14px; background: #FFFFFF; color: #669999; } table.news_table thead tr ...{ color: #FFFFFF; background: #0099CC; border-bottom: 2px solid #FF0000; padding: 2px 10px; } table.news_table tbody tr ...{ padding: 2px 10px; }</style> <!--end stylesheet--> <mce:script type="text/javascript" language="javascript"><!-- var timeout = null; //setInterval函数句柄 var xmlHttp = false; // //初始化XMLHttpRequest对象 function createXmlHttp()...{ xmlHttp = false; if (window.ActiveXObject) ...{ try ...{xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) ...{xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");} }else if (window.XMLHttpRequest) ...{xmlHttp = new XMLHttpRequest();} } //异步调用update.asp页面获取结果timestamp为了不让浏览器缓存结果 function sendRequest()...{ createXmlHttp(); var url = "update.asp?timestamp=" + new Date().getTime(); if (!xmlHttp) ...{ alert("XMLHttpRequest is not Create!"); } xmlHttp.open("GET", url, true); xmlHttp.onreadystatechange = function()...{//回调函数开始 var tag = document.getElementById("container"); tag.innerHTML = ""; if (xmlHttp.readyState == 4 && xmlHttp.status == 200) ...{ tag.innerHTML = xmlHttp.responseText; } }//回调函数结束 xmlHttp.send(null); } //开始自动刷新 function update()...{ timeout = window.setInterval("sendRequest()", 4000);//设定4秒调用一次update.asp页面 } //停止自动刷新 function Stopupdate()...{ if (timeout != null) ...{ window.clearInterval(timeout); } } // --></mce:script> </head> <body onLoad="sendRequest();"> <input type="button" value="Start Fresh" onClick="update();"/> <input type="button" value="Stop Fresh" onClick="Stopupdate();"/> <div id="container"><!--容器--></div> </body> </html>
3:
我认为在ASP中最好的办法是用编程实现定时刷新Cache,也就是说给Application中储存的设一个过期时间。当然,在ASP中Application对象没有这样一个ExpireTime属性。这需要用程序实现。
Code
ASP:default.asp
<%@Language=VBScript%> <%Option Explicit%> <%Response.Buffer=True%> <!--#include file = "conn.asp"--> <!--#include file = "GetCache.asp"--> <HTML> <HEAD> <TITLE>ASP Cache演示</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"> </HEAD> <BODY> <h4>每隔10秒刷新Cache:</h4> <% response.Flush GetHTMLStream response.Write HTMLStream %> </body> </html>
ASP:getcache.asp
<% Const CACHE_DEFAULT_INTERVAL = 30 '每隔30秒刷新一次cache Dim HTMLStream Dim IsExpires IsExpires = CacheExpires Function CacheExpires Dim strLastUpdate Dim result strLastUpdate = Application("LastUpdate") If (strLastUpdate = "") Or (CACHE_DEFAULT_INTERVAL < DateDiff("s", strLastUpdate, Now)) Then result = true SetLastUpdateTime Else result = false End If CacheExpires = result End Function %>
上面是一个最简单的例子。
4:
最好的自动刷新代码
<mce:script language="JavaScript"><!-- //configure refresh interval (in seconds) var countDownInterval=60; //configure width of displayed text, in px (applicable only in NS4) var c_reloadwidth=200 // --></mce:script> <ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer><mce:script type="text/javascript"><!-- var countDownTime=countDownInterval+1; function countDown(){ countDownTime--; if (countDownTime <=0){ countDownTime=countDownInterval; clearTimeout(counter) window.location.reload() return } if (document.all) //if IE 4+ document.all.countDownText.innerText = countDownTime+" "; else if (document.getElementById) //else if NS6+ document.getElementById("countDownText").innerHTML=countDownTime+" " else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.reload()" mce_href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds') document.c_reload.document.c_reload2.document.close() } counter=setTimeout("countDown()", 1000); } function startit(){ if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN document.write('离下一次<a href="javascript:window.location.reload()" mce_href="javascript:window.location.reload()">刷新</a>还有 <b id="countDownText">'+countDownTime+' </b>秒') countDown() } if (document.all||document.getElementById) startit() else window.onload=startit // --></mce:script>
5:
在<head></head>加入以下代码
<meta http-equiv=refresh content="2; url=test.asp">
content 是间秒数
相关文章推荐
- ASP网页在载入时自动刷新两次代码
- html网页自动刷新代码
- 网页自动刷新代码
- 网页页面 自动刷新的3种代码
- 网页自动跳转/定时跳转代码
- 使用Meta自动定时刷新页面及一些HTML标记
- 网页页面 自动刷新的3种代码
- 一段网页上自动播放视频的Html代码【非常好用】
- PHP定时自动生成静态HTML的实现代码
- 如何让asp.net应用程序定时自动执行代码
- 网页页面 自动刷新的3种代码
- 网页自动刷新代码
- html基础-图片标签、表格的属性、链接的属性及链接的分类、name定义锚点的名称、网页的自动刷新、基本字符
- 网页页面实现自动刷新的3种代码
- 如何让asp.net应用程序定时自动执行代码 [ 光影人像 东海陈光剑 的博客 ]
- 网页自动刷新代码
- ASP.NET 页面刷新和定时跳转代码整理
- Selenium定时刷新网页的实现代码
- html网页自动跳转代码大全
- html网页自动跳转代码的两种方案