Core JavaScript

Intermediate JavaScript

JavaScript Reference

JavaScript Timing Events




JavaScript setTimeout() function use to create a timing events. Following example is click on button after 2 second alertbox will be open.

JavaScript setTimeout() Function

Syntax:

var time=setTimeout("javascript_statement",milliseconds);

Example-Code

<script type="text/javascript">
function tMessage()
{
var time=setTimeout("alert('when you click press, Alert Box Open has
been 2 seconds!')",2000);
}
</script>
<form>
<input type="button" value="Click Here Alert Box" onClick="tMessage()"/>
</form>

Example-Result: