setTimeOut (رمز ، ميليسيك) //- قم بتنفيذ الرمز بعد الوقت المحدد
الرمز يجب ؛
يجب على ميليسيك ؛
ClearTimeOut (setTimeOutId) //- إلغاء setTimeOut ()
SetInterval (رمز ، ميليسيك) ؛
الرمز يجب ؛
يجب على ميليسيك ؛
ClearInterval (الفاصل) ؛
استخدم setTimeOut (الكود ، millisec) لتحقيق تأثير setInterval ، فقط أساليب الاتصال المتداخلة ؛
فيما يلي صفحة العد التنازلي
نسخة الكود كما يلي:
<! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en"
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = gb2312" />
<title> Unted Document </title>
<script type = "text/javaScript">
var c = 6 ؛
var t ؛
وظيفة timedCount ()
{
var time = document.getElementById ('txt'). value ؛
if (time> 0) {
document.getElementById ('txt'). value = c ؛
C = C-1 ؛
t = setTimeout ("timedCount ()" ، 1000) ؛
}
آخر{
ClearTimeout (t) ؛
}
}
</script>
</head>
<body>
<Porm>
<type = "زر" value = "وقت البدء!"
<type type = "text" id = "txt" value = "6">
</form>
</body>
</html>