|
||
| Inside Technique : Countdown Timer Create a countdown timer. Use this timer when you want an action to occur after a certain amount of time. To experiment with this example, type in a number in the text box below and click on "Go". The timer will count down the seconds. DescriptionThe element with the ID of "howMany" contents are updated with the countdown. To start the countdown, the function Code
function countDown() {
var el = document.all.howMany
el.innerText--
if (0<=el.innerText)
setTimeout("countDown()",1000)
else {
// Replace following with custom action.
el.innerHTML = "Do Action Now"
// The following line is only necessary to reenable the "Go" button
document.all.go.disabled=false;
}
}
© 1997-2000 InsideDHTML.com, LLC. All rights reserved. |