个人感觉完全为了Ajax而Ajax就不好了!JavaScript在客户端处理不是更理想吗?
复制代码 代码如下:
function Timer(span)
{
var tmp = new Date();
var milsecs=Date.parse(tmp.getMonth()+"-"+tmp.getDay()+"-"+tmp.getFullYear()+" "+document.getElementById('lbl_Hour').innerText+":"+document.getElementById('lbl_Minute').innerText+":"+document.getElementById('lbl_Second').innerText);
var timer = new Date(milsecs+span);
var seconds,minutes,hours,date;
if(timer.getSeconds()<10)
seconds = "0"+timer.getSeconds();
else
seconds = timer.getSeconds();
if(timer.getMinutes()<10)
minutes = "0"+timer.getMinutes();
else
minutes = timer.getMinutes();
if(timer.getHours()<10)
hours = "0"+timer.getHours();
else
hours = timer.getHours();
date=timer.getDate();
document.getElementById('lbl_Second').innerText = seconds;
document.getElementById('lbl_Minute').innerText = minutes;
document.getElementById('lbl_Hour').innerText = hours;
}
//得到服务器时间每隔updatespan分钟校验一次,每秒更新一次本地时钟
function GetServerTime(updatespan)
{
var clientspan = 1*1000;
//更新本地时钟
setInterval("Timer("+clientspan+")",clientspan);
//同步服务器时钟
setInterval("window.location.href='当前URL'", updatespan);
}
复制代码 代码如下:
function Timer(span)
{
var tmp = new Date();
var milsecs=Date.parse(tmp.getMonth()+"-"+tmp.getDay()+"-"+tmp.getFullYear()+" "+document.getElementById('lbl_Hour').innerText+":"+document.getElementById('lbl_Minute').innerText+":"+document.getElementById('lbl_Second').innerText);
var timer = new Date(milsecs+span);
var seconds,minutes,hours,date;
if(timer.getSeconds()<10)
seconds = "0"+timer.getSeconds();
else
seconds = timer.getSeconds();
if(timer.getMinutes()<10)
minutes = "0"+timer.getMinutes();
else
minutes = timer.getMinutes();
if(timer.getHours()<10)
hours = "0"+timer.getHours();
else
hours = timer.getHours();
date=timer.getDate();
document.getElementById('lbl_Second').innerText = seconds;
document.getElementById('lbl_Minute').innerText = minutes;
document.getElementById('lbl_Hour').innerText = hours;
}
//得到服务器时间每隔updatespan分钟校验一次,每秒更新一次本地时钟
function GetServerTime(updatespan)
{
var clientspan = 1*1000;
//更新本地时钟
setInterval("Timer("+clientspan+")",clientspan);
//同步服务器时钟
setInterval("window.location.href='当前URL'", updatespan);
}
标签:
动态显示,当前时间
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“.net动态显示当前时间(客户端javascript)”评论...