setimeout(code、millisec)//-指定された時間後にコードを実行します
コードはしなければなりません。
ミリセックはしなければなりません。
ClearTimeOut(setimeoutid)//-cancel setimeout()
setinterval(コード、millisec);
コードはしなければなりません。
ミリセックはしなければなりません。
ClearInterval(intervalid);
Settimeout(Code、Millisec)を使用して、ネストされた呼び出し方法のみを実現します。
以下はカウントダウンページです
コードコピーは次のとおりです。
<!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">
<head>
<Meta http-equiv = "content-type" content = "text /html; charset = gb2312" />
<title> un unt ittitled document </title>
<script type = "text/javascript">
var c = 6;
var t;
function timedcount()
{
var time = document.getElementById( 'txt')。value;
if(time> 0){
document.getElementById( 'txt')。value = c;
C = C-1;
t = setimeout( "timedcount()"、1000);
}
それ以外{
cleartimeout(t);
}
}
</script>
</head>
<body>
<form>
<入力タイプ= "button" value = "start time!" onclick = "">
<入力型= "text" id = "txt" value = "6">
</form>
</body>
</html>