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:
<input type="button" value="get message" onclick="getMessage();"/>
<script language="javascript">
function getMessage()
{
var timeOut = setTimeout ( "alert( 'Delay of 5 seconds!!!' )" , 5000);
}
</script>
In the above example setTimeout function will display the alert message box after 5000 milliseconds i.e. 5 seconds.
Currently rated 5.0 by 1 people
Tags: javascript, javascript settimeout, javascript delay, javascript time, javascript use, javascript tutorials, learn javascript, javascript examples
8/23/2008 9:09:15 PM