settimeout (code, millisec) //- 지정된 시간 후에 코드를 실행합니다
코드는해야합니다.
Millisec은해야합니다.
Cleartimeout (settimeoutID) //- 취소 settimeout ()
SetInterval (Code, Millisec);
코드는해야합니다.
Millisec은해야합니다.
ClearInterval (IntervalId);
Settimeout (Code, Millisec)을 사용하여 SetInterval 효과를 달성하고 중첩 된 호출 방법 만 달성하십시오.
아래는 카운트 다운 페이지입니다
코드 사본은 다음과 같습니다.
<! doctype html public "-// w3c // dtd xhtml 1.0 Transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = gb2312" />
<title> 제목의 문서 </title>
<script type = "text/javaScript">
var c = 6;
var t;
함수 timedCount ()
{
var time = document.getElementById ( 'txt'). 값;
if (time> 0) {
document.getElementById ( 'txt'). value = c;
C = C-1;
t = settimeout ( "timedCount ()", 1000);
}
또 다른{
클리어 타임 아웃 (t);
}
}
</스크립트>
</head>
<body>
<양식>
<입력 유형 = "버튼"value = "시작 시간!"
<입력 유형 = "text"id = "txt"value = "6">
</form>
</body>
</html>