setTimeOut (código, milisec) //- ejecute el código después del tiempo especificado
El código debe;
Millisec debe;
ClearTimeOut (setTimeOutid) //- CancelateStimeOut ()
setInterval (código, milisec);
El código debe;
Millisec debe;
ClearInterval (Interválido);
Use SetTimeOut (Código, Millisec) para lograr el efecto SetInterval, solo métodos de llamadas anidadas;
A continuación se muestra una página de cuenta regresiva
La copia del código es la siguiente:
<! DocType html public "-// w3c // dtd xhtml 1.0 Transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transicional.dtd ">
<html xmlns = "http://www.w3.org/1999/xhtml">
<Evista>
<meta http-equiv = "content-type" content = "text /html; charset = gb2312" />
<title> un documento titulado </title>
<script type = "text/javaScript">
var c = 6;
var t;
función TimedCount ()
{
var tiempo = document.getElementById ('txt'). valor;
if (tiempo> 0) {
document.getElementById ('txt'). valor = c;
C = C-1;
t = setTimeOut ("TimedCount ()", 1000);
}
demás{
ClearTimeOut (t);
}
}
</script>
</ablo>
<Body>
<form>
<input type = "Button" Value = "Start Time!"
<input type = "text" id = "txt" value = "6">
</form>
</body>
</html>