Este artigo descreve o método completo de implementação do JavaScript Timer. Compartilhe para sua referência. O método de implementação específico é o seguinte:
Copie o código da seguinte forma: <!
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> Temporizador </title>
<script type = "text/javascript">
Var Timer = NULL;
função begin () {
var date = new Date ();
var current_time = date.getlyear () + '-' + date.getMonth () + '-' + date.getDate () + '';
current_time + = date.gethours () + ':' + date.getminutes () + ':' + date.getSeconds ();
document.getElementById ('current_time'). value = current_time;
Timer = setTimeout ('BEGIN ()', 1000);
}
function end () {
ClearTimeout (timer); // Limpe o objeto do timer
}
</script>
</head>
<Body>
<input type = "text" name = "current_time" id = "current_time"/> <input type = "button" value = "start" onclick = "begin ();">
<input type = "button" value = "end" onclick = "end ();"/> <br/>
</body>
</html>
Espero que este artigo seja útil para a programação JavaScript de todos.