Objekte: Date
Script:
<html><head>
<title>Javascript</title>
<script language="JavaScript">
<!--
var t1, id;
function start()
{
var time;
time=new Date();
t1=time;
messen();
}
function messen()
{
var t2;
t2=new Date()
var tdif;
tdif=t2-t1;
var ts;
ts=tdif/1000;
document.clock.digits.value=ts;
id=setTimeout("messen()",10);
}
function stop()
{
clearTimeout(id);
}
//-->
</script>
</head>
<body>
<form name="clock">
Zeit bisher in Sekunden:<br>
<input type="text" name="digits" size=12><p>
<input type="button" value="Start" onClick="start()">
<input type="button" value="Stop" onClick="stop()">
</form>
</body></html>
Ergebnis:
--------------------------------------------------------------
hier:
- Date
- Methoden des Objektes Date
- setTimeout("Funktion()",Zeit);
- clearTimeout()