復制代碼 代碼如下:
<script language ="javascript" type ="text/javascript">
var second=0;
var minute=0;
var hour=0;
window .setInterval ("OnlineStayTimes();",1000);
function OnlineStayTimes()
{
second ++;
if(second ==60){second =0;minute +=1;}
if(minute ==60){minute =0;hour +=1;}
var tm=hour+"小時"+minute +"分鐘"+second +"秒"
document.getElementById ("time").innerHTML=tm;
}
</script>
上面代碼中document.getElementById ("time").innerHTML=tm;中“time”是label的id,這樣即可實現顯示在線時間的功能!