setInterval method

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


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


  • expression [in]
    Type: VARIANT

    Pointer to a VARIANT that specifies a 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

    Pointer to a BSTR that specifies any one of the possible values for the IHTMLElement::language attribute.

Standards information

There are no standards that apply here.


The IHTMLWindow2::setInterval method continuously evaluates the specified expression until the timer is removed with the IHTMLWindow2::clearInterval 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 Examples.

In versions earlier than Microsoft Internet Explorer 5, the first argument of IHTMLWindow2::setInterval must be a string. Evaluation of the string is deferred until the specified interval elapses.

As of Internet Explorer 5, the first argument of IHTMLWindow2::setInterval can be passed as a string or as a function pointer.

See also