Search w3schools.com:

SHARE THIS PAGE

Window setTimeout() Method

Window Object Reference Window Object

Definition and Usage

The setTimeout() method calls a function or evaluates an expression after a specified number of milliseconds.

Tip: 1000 ms = 1 second.

Syntax

setTimeout(code,millisec,lang)

Parameter Description
code Required. The function that will be executed
millisec Required. The number of milliseconds to wait before executing the code
lang Optional. The scripting language: JScript | VBScript | JavaScript


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The setTimeout() method is supported in all major browsers.


Example

Example

Display an alert box after 3 seconds:

var t=setTimeout(function(){alert("Hello")},3000)

Try it yourself »


Examples

More Examples

Display a timed text

Count forever - with a Stop button

A clock created with timing events


Window Object Reference Window Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]