希望我这个简单的代码能够帮到你了,
<html>
<head>
<script language="javascript">
var seconds=0;
var minutes=0;
var hours=0;
function timer()
{
seconds++;
if(seconds==60)
{
minutes++;
seconds=0;
}
if(minutes==60)
{
hours++;
minutes=0;
}
text.innerHTML=hours+"时"+minutes+"分"+seconds+"秒"
setTimeout("timer()",1000);
/* var d=new Date();
var hours=d.getHours();
var minutes=d.getMinutes();
var seconds=d.getSeconds();
text.innerHTML=hours+"时"+minutes+"分"+seconds+"秒";
setTimeout("timer()",1000)*/
}
</script>
</head>
<body>
你的现在的在线时间是:
<span id="text"></span>
<script language="javascript">
timer();
</script>
</body>
</html>