Share via


setTimeout method

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

Syntax

 retVal = object.setTimeout(expression, msec, language);

Parameters

expression [in]

Type: VARIANT

Pointer to a VARIANT that specifies the function pointer or string that indicates the code to be executed when the specified interval has elapsed.

msec [in]

Type: long

long that specifies the number of milliseconds.

language [in, optional]

Type: VARIANT

BSTR that specifies one of the following values:

JScript

Language is JScript.

VBScript

Language is VBScript.

JavaScript

Language is JavaScript.

Standards information

There are no standards that apply here.

Remarks

The specified expression or function is evaluated once. For repeated evaluation, use the IHTMLWindow2::setInterval or IHTMLWindow2::setInterval method.

Note  In Windows Internet Explorer, you cannot pass arguments to the callback function directly; however, you can simulate passing arguments by creating an anonymous closure function that references variables within scope of the call to IHTMLWindow2::setInterval or IHTMLWindow2::setTimeout. For more information, see IHTMLWindow2::setInterval.

 

The first argument of IHTMLWindow2::setTimeout can be a string or a function pointer.

See also

IHTMLWindow2::clearTimeout

requestAnimationFrame

setImmediate

IHTMLWindow2::setInterval