Javascript setTimeout function evaluates the expression after the time specified in milliseconds. setTimeout function of Javascript delays the execution of the function or expression specified with the time specified.

Javascript setTimeout syntax

setTimeout(expression, msec, lang);

setTimeout function takes 3 parameters

Expression: Name of the function to call or the javascript expression to evaluate.

Msec:  Time in milliseconds after which the specified expression is evaluated.

Lang: Optional parameter to specify the scripting language e.g.: Jscript, Javascript, vbscript.

Javascript setTimeout Example

function getMessage()
{
    var timeOut = setTimeout ( "alert( 'Delay of 5 seconds!!!' )" , 5000);
}

In the above example setTimeout function will display the alert message box after 5000 milliseconds i.e. 5 seconds.

Continue to next tutorial: JavaScript clearTimeout to learn how to stop the timer event.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.