The javascript is a timer that counts down how do I change the style using css?
(or any other alternative)
I need the script to close the window when the timers reaches 0 but it doesn't happen. what Is going wrong?
Is there any way to integrate the countdown as a progress bar?
<span id="countdown"></span>
<script type="text/javascript">
// set the date we're counting down to
var target_date = new Date().getTime();
var delay = 10;
// variables for time units
var days, hours, minutes, seconds;
// get tag element
var countdown = document.getElementById("countdown");
// update the tag with id "countdown" every 1 second
setInterval(function () {
// find the amount of "seconds" between now and target
var current_date = new Date().getTime();
var seconds_left = (current_date - target_date) / 1000;
var a = (delay - seconds_left);
// do some time calculations
minutes = parseInt(a / 60);
seconds = parseInt(a % 60);
// format countdown string + set tag value
countdown.innerHTML = minutes + "m: " + seconds + "s";
if (seconds_left > delay) {
setTimeout(action(), 10);
}
}, 1000);
var action = function () {
close();
}
</script>