<script type="text/javascript">
<!--//建立XMLHttpRequest对象
var xmlhttp;
try{
xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
}catch(e){
try{
xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
}catch(e){
try{
xmlhttp= new XMLHttpRequest();
}catch(e){}
}
}function getPart(url){
xmlhttp.open("get",url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
if(xmlhttp.responseText!=""){
document.getElementById("partdiv").innerHTML = unescape(xmlhttp.responseText);
}
}
else{
document.getElementById("partdiv").innerHTML = "数据载入出错";
}
}
}
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.send(null);
}
setInterval("getPart('getPart.asp')",1000)
//-->
</script>
是这个吗?但是怎么用啊
<!--//建立XMLHttpRequest对象
var xmlhttp;
try{
xmlhttp= new ActiveXObject('Msxml2.XMLHTTP');
}catch(e){
try{
xmlhttp= new ActiveXObject('Microsoft.XMLHTTP');
}catch(e){
try{
xmlhttp= new XMLHttpRequest();
}catch(e){}
}
}function getPart(url){
xmlhttp.open("get",url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4)
{
if(xmlhttp.status == 200)
{
if(xmlhttp.responseText!=""){
document.getElementById("partdiv").innerHTML = unescape(xmlhttp.responseText);
}
}
else{
document.getElementById("partdiv").innerHTML = "数据载入出错";
}
}
}
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.send(null);
}
setInterval("getPart('getPart.asp')",1000)
//-->
</script>
是这个吗?但是怎么用啊
setInterval("refreshTime()",1000); //每格1秒Z新一次
funciton refreshTime()
{
var dateObj = new Date();
time.innerHTML = dateObj.toLocaleDateString();
}
</script>
<?php
$time=date("Y-m-d H:i:s");
?>
<div id=time><?php echo $time;?></div>这个简单的例子应该怎么改改啊,才能让它自动刷新!
setInterval("refreshTime()",1000); //每格1秒Z新一次
funciton refreshTime()
{
var dateObj = new Date();
document.getElementById("time").innerHTML = dateObj.toLocaleDateString();
}
</script>
<?php
$time=date("Y-m-d H:i:s");
?>
<div id="time"> <?php echo $time;?> </div>