/ Published in: JavaScript
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.
gets placed where you want the counter.
Enjoy.
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.
gets placed where you want the counter.
Enjoy.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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!"; } }