計時器

停留時間:

原始檔如下..

<html>
<title>計時器</title>
<head>
<script>
startday = new Date();
clockStart = startday.getTime();
function initStopwatch()
{
var myTime = new Date();
var timeNow = myTime.getTime();
var timeDiff = timeNow - clockStart;
this.diffSecs = timeDiff/1000;
return(this.diffSecs);
}
function getSecs()
{
var mySecs = initStopwatch();
var mySecs1 = ""+mySecs;
mySecs1= mySecs1.substring(0,mySecs1.indexOf(".")) + "秒";
document.forms[0].timespent.value = mySecs1
window.setTimeout('getSecs()',1000);
}
</script>
</head>
<body onLoad="window.setTimeout('getSecs()',1)">
<CENTER><form>
停留時間:
<input size=9 name=timespent>
</form></CENTER><p>
</body>
</html>