setTimeOut ()-يستخدم لتحديد أن البرنامج يتم تنفيذه بعد فترة زمنية محددة.
شكل:
[اسم كائن المؤقت =] setTimeOut ("<spression>" ، milliseconds) ؛
الوظيفة: تنفيذ <spression> مرة واحدة.
حيث التعبير عبارة
نسخة الكود كما يلي:
<html>
<head>
<script type = "text/javaScript">
// تنفيذ التنبيه بعد 5 ثوان
عدد الوظائف () {
setTimeout ("Alert ('Execution Success") ؛ "، 5000) ؛
}
</script>
</head>
<body>
<type type = "button" value = "execute" onClick = "count ()">
</body>
</html>
setInterval () - كرر تنفيذ <Spression> حتى يتم إغلاق النافذة أو الإطار أو تنفيذ ClearInterval
التنسيق: [اسم كائن Timer =] SetInterval ("<spression>" ، ميلي ثانية)
ClearInterval () ينتهي المؤقت
التنسيق: ClearInterval (اسم كائن المؤقت)
نسخة الكود كما يلي:
<html>
<head>
<script type = "text/javaScript">
var sec = 0 ؛
var timeId = setInterval ("count () ؛" ، 1000) ؛
عدد الوظائف () {
document.getElementById ("num"). innerhtml = sec ++ ؛
}
وظيفة stopcount () {
Clearinterval (TimeId) ؛
}
</script>
</head>
<body>
<font style = "color: red" id = "num"> 0 </font> selections <input type = "button" value = "stop" onClick = "stopCount () ؛">
</body>
</html>
هل هو مفيد جدا؟ يرجى الرجوع إليها إذا كنت في حاجة إليها.