使用一般方法:将下面的代码添加到页面的<header></header> 之间
< meta http-equiv ="refresh" content ="5" URL ="Example.aspx" />
使用javascript 和JQuery 脚本实现 ,效果如下图所示
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server">
< title > 定时刷新页面</ title >
< script type ="text/javascript" language ="javascript" src ="scripts/jquery.min.js"></ script >
< script type ="text/javascript" language ="javascript">
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 + " 秒后重刷本页!"
$("#myDiv1" ).find("span" ).html(curtime);
setTimeout("beginrefresh()" , 1000)
}
}
$(function () {
beginrefresh();
showTime();
});
function showTime() {
var date = new Date();
var current_data =" " +date.getFullYear()+" 年" +date.getMonth()+" 月" +date.getDate()+" 日" +date.getHours()+":" +date.getMinutes()+":" +date.getSeconds();
$("#myDiv2" ).find("span" ).html(current_data);
}
</ script >
</ head >
< body bgcolor ="#FFFFFF" text ="#000000">
< form id ="form1" runat ="server">
< div id ="myDiv1">
< span ></ span >
</ div >
< div id ="myDiv2">
< h3 > 当前系统时间:</ h3 >
< span ></ span >
</ div >
</ form >
</ body >
</ html >