Note:
Setinterval and setTimeout are both dhtm window objects.
Differences:
Setinterval (expression, Time): After a page is loaded, the specified expression is executed every time after a specified millisecond value.
SetTimeout (expression, Time): After a page is loaded, the specified expression is executed only once after a specified millisecond value.
Appendix:
You can use the clearInterval and clearTimeout methods to cancel events. For more information, see the DHMTL manual.
The test code is as follows:
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> </title>
<SCRIPT>
VaR Index = 0;
VaR Si;
Function Test (){
VaR test = Document. getelementbyid ("mydiv"). innerhtml;
Index ++;
Test + = index + "<br> ";
Document. getelementbyid ("mydiv"). innerhtml = test;
If (Index = 10 ){
Clearinterval (SI );
}
}
SI = setinterval (test, 1000 );
// SetTimeout (test, 1000 );
</SCRIPT>
</Head>
<Body>
<Div id = "mydiv"> </div>
</Body>
</Html>