Setinterval and setTimeout methods in Javascript

Source: Internet
Author: User
Setinterval Method

Evaluates an expression each time a specified number of milliseconds has
Elapsed.

Syntax

Itimerid
=Window
. Setinterval (
Vcode
,
Imilliseconds
[
,
Slanguage
]
)

Parameters

Vcode

Required.Variant

That specifies a function pointer or string that
Indicates the code to be executed when the specified interval has
Elapsed.

Imilliseconds

Required.Integer

That specifies the number
Milliseconds.

Slanguage

Optional.String

That specifies any one of the possible values
The language
Attribute.

Return Value

Integer. returns an identifier that cancels the timer withClearinterval

Method.

Remarks

TheSetinterval

Method continuously evaluates the specified expression
Until the timer is removed withClearinterval

Method.

In versions earlier than Microsoft Internet Explorer 5, the first argument
OfSetinterval

Must be a string. Evaluation of the string is deferred
Until the specified interval elapses.

As of Internet Explorer 5, the first argumentSetinterval

Can be
Passed as a string or as a function pointer.

To pass a function as a string, be sure to suffix the function name
Parentheses.

window.setInterval("someFunction()", 5000);

When passing a function pointer, do not include the parentheses.

window.setInterval(someFunction, 5000);
SetTimeout Method


Evaluates an expression after a specified number of milliseconds has elapsed.

Syntax

Itimerid
=Window
. SetTimeout (
Vcode
,
Imilliseconds
[
,
Slanguage
]
)

Parameters

Vcode

Required.Variant

That specifies the function pointer or string that
Indicates the code to be executed when the specified interval has
Elapsed.

Imilliseconds

Required.Integer

That specifies the number
Milliseconds.

Slanguage

Optional.String

That specifies one of the following values:

JScript

Language is JScript.
VBScript

Language is VBScript.
Javascript

Language is
JavaScript.

Return Value

Integer. returns an identifier that cancels the evaluation withCleartimeout

Method.

Remarks

In versions earlier than Microsoft Internet Explorer 5, the first argument
OfSetTimeout

Must be a string. Evaluation of the string is deferred
Until the specified interval elapses.

As of Internet Explorer 5, the first argumentSetTimeout

Can be
String or a function pointer.

The specified expression or function is evaluatedOnce

.Repeated

Evaluation, useSetinterval

Method.

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.