当前位置:首页> PHP教程> php基础
关键字
文章内容
利用php和js实现页面数据刷新
 
 
修改时间:[2011/12/16 08:26]    阅读次数:[1013]    发表者:[起缘]
 
利用"XXXX.htm"和"XXX.php"两个文件来实现数据的刷新www.chinaitpower.comDYLHR
XXXX.htmwww.chinaitpower.comDYLHR
<head>www.chinaitpower.comDYLHR
<script>
// Refresh code
r_s = 0;
timenow = 0;
function calrs()
{
d = new Date();
h= d.getHours(); m = d.getMinutes(); s = d.getSeconds();
if( m <10) m = '0' + m;
if( s <10) s = '0' + s;
status = ' ' + h + ":" + m + ":" + s;
r_s = 2000;
}www.chinaitpower.comDYLHR
calrs();www.chinaitpower.comDYLHR
function reload_me()
{
c = document.getElementById("reload1");
c.src = "";
c.src = "XXXXX.php?reload=1";www.chinaitpower.comDYLHR
calrs();
setTimeout('reload_me()', r_s);
}www.chinaitpower.comDYLHR
// Refresh code
setTimeout('reload_me()', r_s);
</script>www.chinaitpower.comDYLHR
<script id="reload1"></script>www.chinaitpower.comDYLHR
</head><small>
<div id="p_show></div>www.chinaitpower.comDYLHR
</small>www.chinaitpower.comDYLHR
www.chinaitpower.comDYLHR
XXXXX.phpwww.chinaitpower.comDYLHR
<?php
header("Cache-Control: no-cache, must-revalidate");
echo "document.all.p_show.innerHTML= "?<font color=red>".rand(0,9)."</font>"";
?>
www.chinaitpower.comDYLHR