Dieser Artikel beschreibt die vollständige Implementierungsmethode von JavaScript Timer. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Kopieren Sie den Code wie folgt: <! DocType html public "-// w3c // dtd html 4.01 transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<kopf>
<meta http-äquiv = "content-type" content = "text/html; charset = utf-8">
<title> Timer </title>
<script type = "text/javaScript">
var timer = null;
Funktion begin () {
var date = new Date ();
var Current_time = Date.getingfullyear () + '-' + Date.getMonth () + '-' + Date.getDate () + '';
current_time + = date.gethours () + ':' + date.getminutes () + ':' + date.getSeconds ();
document.getElementById ('current_time'). value = current_time;
Timer = setTimeout ('begin ()', 1000);
}
Funktion end () {
Clearimeout (Timer); // das Timer -Objekt löschen
}
</script>
</head>
<body>
<input type = "text" name = "currle_time" id = "current_time"/> <Eingabe type = "button" value = "start" onclick = "begin ();">
<Eingabe type = "button" value = "end" onclick = "end ();"/> <br/>
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.