欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

.net動態(tài)顯示當前時間(客戶端javascript)

 更新時間:2009年11月03日 23:54:43   作者:  
剛才在首頁看到 asp.net實現(xiàn)動態(tài)顯示當前時間 這篇文章, 作者用Ajax實現(xiàn)類似時鐘的效果!
個人感覺完全為了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);
}

相關文章

最新評論