Latest web development tutorials

Window setTimeout () method

Window Object Reference Window object

Definition and Usage

setTimeout () method is used to evaluate the expression or function call after a specified number of milliseconds.

Tip: 1000 ms = 1 second.

grammar

setTimeout(code,millisec,lang)

参数 描述
code 必需。要调用的函数后要执行的 JavaScript 代码串。
millisec 必需。在执行代码前需等待的毫秒数。
lang 可选。脚本语言可以是:JScript | VBScript | JavaScript


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support setTimeout () method.


Examples

Examples

Display after 3 seconds a pop:

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

try it"


Examples s

More examples

display time.

Endless cycle timing - with a stop button

Create a time event is always through.


Window Object Reference Window object