var timerid = null;
var timerrunning = false;
function stopclock (){
if(timerrunning)
cleartimeout(timerid);
timerrunning = false;
}
function showtime () {
var now = new date();
var hours = now.gethours();
var minutes = now.getminutes();
var seconds = now.getseconds()
var timevalue = " " + ((hours >12) ? hours -12 :hours)
timevalue += ((minutes < 10) ? ":0" : ":") + minutes
timevalue += ((seconds = 12) ? " pm" : "am"
window.status = timevalue;
document.title = timevalue;
timerid = settimeout("showtime()",1000);
timerrunning = true;
}
function startclock () {
stopclock();
showtime();
}
window.onload=startclock
body { font-family: tahoma; font-size: 9pt; color: #ffffff }
请看状态栏:
[ctrl+a 全选 注:如需引入外部js需刷新才能执行]