В этой статье описывается полный метод реализации таймера JavaScript. Поделитесь этим для вашей ссылки. Конкретный метод реализации следующим образом:
Скопируйте код следующим образом: <! Doctype html public "-// w3c // dtd html 4.01 transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<голова>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> таймер </title>
<script type = "text/javascript">
var timer = null;
функция begin () {
var date = new Date ();
var current_time = date.getfyear () + '-' + date.getmonth () + '-' + date.getDate () + '';
current_time + = date.gethours () + ':' + date.getminutes () + ':' + date.getSeconds ();
document.getElementbyId ('current_time'). value = current_time;
timer = settimeout ('begin ()', 1000);
}
функция end () {
ClearTimeout (таймер); // очистить объект таймера
}
</script>
</head>
<тело>
<input type = "text" name = "current_time" id = "current_time"/> <input type = "кнопка" value = "nath" onclick = "begin ();">
<input type = "button" value = "end" onclick = "end ();"/> <br/>
</body>
</html>
Я надеюсь, что эта статья будет полезна для каждого программирования JavaScript.