Hello, I am not an expert person in javascript. I have collected a javascript count down code from a website code from
another website. But I want to add some features in this code,
First: After the countdown is finished, a code something like 123456 will appear on the screen.
second: when it goes to zero and I switch the tab and come back again to the countdown tab, it again starts the negative
countdown.
Please give the Two solutions by editing the code thus I am not an expert, so please don’t say it in shortcut.
Code is given below
JS Bin $(document).ready(function() { // Create Countdown object var countdown = new Countdown({ seconds: 10 , onUpdateStatus:function(a){ $('#counter').text(a) /* insert code */ }, onCounterEnd: function() { /* insert code */ } }); window.addEventListener('blur', function() {
countdown.stop();
});
window.addEventListener('focus', function() {
countdown.start();
});
// Start the countdown
countdown.start();
});
function Countdown(a) {
function d() {
e(b);
0 === b && (f(), g.stop());
b--
}
var c, g = this,
b = a.seconds,
e = a.onUpdateStatus || function() {},
f = a.onCounterEnd || function() {};
this.start = function() {
clearInterval(c);
c = 0;
c = setInterval(d, 1E3)
};
this.stop = function() {
clearInterval(c)
}
};
</script>