Difference between JavaScript setTimeout and setinterval

Source: Internet
Author: User
[SetTimeout]
SetTimeout (expression, latency)
During execution, the expression is executed once after the specified time delay after loading. Remember, the number of times is once.

The effect of the random number is displayed automatically when the setTimeout function is used:

<HTML>
<Head>
<SCRIPT>
Window. onload = sett;
Function sett ()
{
Document. Body. innerhtml = math. Random ();
SetTimeout ("sett ()", 500 );
}
</SCRIPT>
</Head>
<Body>
</Body>
</Html>

[Setinterval]
Setinterval (expressiveness, interaction time)
It executes the expression once every specified time after loading.

The effect of the random number is displayed automatically when setinterval is used:

<HTML>
<Head>
<SCRIPT>
Function sett ()
{
Document. Body. innerhtml = math. Random ();
}
Setinterval ("sett ();", 500 );
</SCRIPT>
</SCRIPT>
</Head>
<Body>
</Body>

</Html>

 

From: http://www.cnblogs.com/ruxuan/archive/2006/07/04/442490.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.