Revision: 59653
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 22, 2012 08:56 by warbear
Initial Code
var seconds = 70; var alarm1 = 60; var alarm2 = 30; var alarm3 = 10; var int = window.setInterval("countdown()",1000); function countdown(){ seconds--; var count = document.getElementById("count"); count.innerHTML = seconds; if (seconds <= alarm1) { count.innerHTML = "<span id=alert1>" + seconds + "</span>"; } if (seconds <= alarm2) { count.innerHTML = "<span id=alert2>" + seconds + "</span>"; } if (seconds <= alarm3) { count.innerHTML = "<span id=alert3>" + seconds + "</span>"; } if (seconds == 0){ window.clearInterval(int); // window.location = "location"; count.innerHTML = "Finished!"; } }
Initial URL
Initial Description
var seconds: set this to what you want the count down to start at. var alarm1 etc: set these values to your thresh hold values in either a style tag, or css file, define how you want the appearance to be with the tags of: alert1 alert2 alert3. <div> </div> gets placed where you want the counter. Enjoy.
Initial Title
CountDown with Thresh-holds
Initial Tags
Initial Language
JavaScript