dimanche 29 mars 2015

javascript alert box which shows countdown timer


Vote count:

0




How can I display my countdown timer in javascript alert box.


alert box should be only one. The content in it must be changed.


I want to saw the timer in alert box.


for example.


enter image description here


Here is my code.



<html>
<head>
<title></title>
<script>
var end = new Date('04/01/2015');
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;
var content = "";
function showRemaining() {
var now = new Date();
var distance = end.getTime() - now.getTime();
if (distance < 0) {

clearInterval(timer);
document.getElementById('countdown').innerHTML = 'EXPIRED!';

return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor((distance % _day) / _hour);
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);

document.getElementById('countdown').innerHTML = days + 'days ';
document.getElementById('countdown').innerHTML += hours + 'hrs ';
document.getElementById('countdown').innerHTML += minutes + 'mins ';
document.getElementById('countdown').innerHTML += seconds + 'secs';

}

timer = setInterval(showRemaining, 1000);



</script>
</head>
<body onload="window.alert()">
<div id="countdown"></div>
</body>
</html>


where should I put my javascript alert box. Please guide me towards this.


Thanks in advance.



asked 27 secs ago







javascript alert box which shows countdown timer

Aucun commentaire:

Enregistrer un commentaire