تصف هذه المقالة طريقة التنفيذ الكاملة لمؤقت JavaScript. شاركه للرجوع إليه. طريقة التنفيذ المحددة هي كما يلي:
انسخ الرمز على النحو التالي: <! doctype html public "-// w3c // dtd html 4.01 Transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv = "content-type" content = "text/html ؛ charset = utf-8">
<title> مؤقت </title>
<script type = "text/javaScript">
var timer = null ؛
وظيفة البداية () {
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) ؛
}
وظيفة نهاية () {
ClearTimeout (مؤقت) ؛ // امسح كائن المؤقت
}
</script>
</head>
<body>
<type type = "text" name = "current_time" id = "current_time"/> <input type = "button" value = "start" onClick = "begin () ؛">
<type type = "button" value = "end" onClick = "end () ؛"/> <br/>
</body>
</html>
آمل أن تكون هذه المقالة مفيدة لبرمجة JavaScript للجميع.