JavaScript页面延时刷新

效果:在设置的秒数后自动刷新。适合实时更新的页面。

<script>
<!--
var limit="0:5" //设置刷新时间,格式“分:秒”
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+"分"+cursec+"秒后重刷本页!"
else
curtime=cursec+"秒后重刷本页!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
window.onload=beginrefresh
//-->
</script>

This entry was posted in Technology and tagged , . Bookmark the permalink. 5,046 views

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *