自動增長。javascript
http://www.w3schools.com/jsref/met_win_setinterval.aspjava
While loading the page get the server time in long and create a Date(millis)
Object with Javascript
.jsp
Then use setInterval()
with 1 sec and display.spa
In you Jspcode
var jsVar= <% dateMillis %>; // server millis
and javascript date formationorm
var d = new Date(); d.setTime(jsVar); // server millis ex :1332403882588
Then show in JSserver
var x = document.getElementById("timelable"); x.innerHTML=d.getMilliseconds(); // Modify as per your format
Thenip
window.setInterval(Yourfunction,milliseconds);##"function_name" 須要雙引號
Then in your Yourfunction
add 1 sec to your millis and refresh lable
get
參考博文 http://stackoverflow.com/questions/19515138/displaying-server-time-on-jsp-pageit