Changes

JavaScript Timeouts

890 bytes added, 19:07, 10 May 2007
Cancelling a JavaScript Timeout
</pre>
 
== Setting up JavaScript Timeout to Repeat ==
 
You may have noticed that there is no argument to the ''setTimeout()'' method to tell javaScript to repeat the timeout once it has expired. If, once the timeout has triggered, you need to run the timeout again all you need to do is make another call to ''setTimeout()'' within the function that was called when the timeout was triggered. We can see this in action by extendingf our origianl example. The example below a function we have named ''timedout()'' is called after 10000 milliseconds. After the alert dialog is dismissed by the user the timeout is set up again so that the process will repeat:
 
<pre>
 
<script language="JavaScript" type="text/javascript">
 
id=window.setTimeout ("alert('Timed out')", 20000);
 
function timedout()
{
alert("Timed out");
id=window.setTimeout ("alert('Timed out')", 20000);
}
 
</script>