A Timeout Processing Example : Timer « Development « JavaScript DHTML






A Timeout Processing Example

<HTML>
<HEAD>
<TITLE>Timeout Program</TITLE>
<SCRIPT LANGUAGE="JavaScript"><!--
function setTimer() {
 timer=setTimeout("alert('Too slow!')",10000)
}
function clearTimer() {
 clearTimeout(timer)
 alert("Hi!")
}
// --></SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript"><!--
setTimer()
// --></SCRIPT>
<FORM>
<INPUT TYPE="BUTTON" VALUE="Click here within ten seconds." ONCLICK="clearTimer()">
</FORM>
</BODY>
</HTML>

           
       








Related examples in the same category

1.Using a Timer
2.setInterval() and clearInterval() methods
3.A Countdown Timer
4.Timer Events Demo
5.Timer Events Demo 2
6.Accessing Document Contents