还不太好,我不想让浏览器这样累,只是想在PHP内部实现一个时钟,然后在时钟内部插入其他代码:就像下面的JAVA程序:
<SCRIPT language=JAVASCRIPT>
var timerID = null;
var timerRunning = false;
function stopclock()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock()
{
stopclock();
showtime();
}
function showtime()
{
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" +hours;
//定时初始化数据库的代码:
document.Calc.time.value = timeValue;
// you could replace the above with this
// and have a clock on the status bar:
// window.status = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
return '';
}
</script>