复制代码 代码如下:
<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,这样即可实现显示在线时间的功能!