Javascript:settimeout () use and setinterval () use __java

Source: Internet
Author: User
Tags setinterval

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

(executes the specified expression after the specified time)


Syntax:itimerid = Window.settimeout (Vcode, Imilliseconds [, Slanguage])

Parameters

Vcode Required. Variant that specifies the function pointer or string This indicates the code to is executed when the specified interval h As elapsed.
Imilliseconds Required. Integer that specifies the number of 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 this cancels the evaluation with the Cleartimeout method.

==============================================================



-------------------------------------------------------------------
settimeout (Alert ("3 seconds Passed"), 3000);//Call a function that allows constant arguments
-------------------------------------------------------------------

<mce:script language= "Javascript" ><!--//by zuoyang var x = 1; var y = 2; var z = 3; var sum; function Plus (A, b) {var z = 0; var i = 0; for (i = 0; i < arguments.length; i++) {z = = Arguments[i];} settimeout (f Unction () {alert (z);}, 6000); Can return z with variable parameter settimeout call form; } settimeout (function () {sum = Plus (x, y, z);}, 3000);///////--></mce:script> In addition to the settimeout invocation form that can be used with variable parameters to get the return value.

The use of SetInterval () is the same as settimeout ():


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



The difference is that settimeout () is a one-time action, and SetInterval () performs a vcode every imilliseconds. (evaluates an expression a specified number of milliseconds has elapsed)

Related Article

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.