JavaScript Timer Events

With JavaScript, it is possible to execute some code NOT immediately after a function is called, but after a specified time interval. This is called timing events.

<html>
<head>
<script type=”text/javascript”>
function timedMsg()
{
var t=setTimeout(“alert(‘5 seconds!’)”,5000)
}
</script>
</head>
<body>

<form>

<input type=”button” value=”Display timed alertbox!” onClick = “timedMsg()”>
</form>

<p>Click on the button above. An alert box will be displayed after 5 seconds.</p>

</body>

</html>

Click on the button above. An alert box will be displayed after 5 seconds.

Note: There are 1000 milliseconds in one second.

Posted in Client Side Scripting Tagged with:

Ads