Breaking News

 

 

CountDown timer , Revers Timer watch by javascript code

 

Hi friends

 

If you need countdown counter then this code of javascript is very useful and easy to understanding . This example show watch but it move down

and you can easly modify and use


//------ javascript code


<script type="text/javascript">

Number.prototype.toMinutesAndSeconds = function() {

var m = Math.floor(this / 60);

var s = this % 60;

return (m + ":" + (s < 10 ? "0" : "") + s);

}

function _TDisplay()

{ } _TDisplay.prototype.init = function(seconds, output, notify) {

this.tot = seconds; this.out = output;

this.not = notify; this.ii = setInterval(this.tick, 1000);

}

;_TDisplay.prototype._tick = function() {

this.out.innerHTML = (--this.tot).toMinutesAndSeconds();

if (!this.tot) {

// this.not.innerHTML = 'Time is up baby';

alert('Time is up');

clearInterval(this.ii);

} if (this.tot <= 10)

{ this.not.innerHTML = 'Just ' + this.tot + ' seconds left'; }

}

TDisplay = new _TDisplay(); _TDisplay.prototype.tick = function() {

TDisplay._tick.call(TDisplay);

}

pre = (window.onload) ? window.onload : function()

{ };

window.onload = function()

{ pre(); TDisplay.init(601, document.getElementById('countdown'), document.getElementById('notifier')); }

 

</script>



//       and use in html page code


<div id="countdown"

style="border: 1px solid #0000FF; background-color: #FF0000; font-family: 'Times New Roman', Times, serif; font-size: large; font-weight: bold; text-transform: capitalize; color: #000000; width: 46px; height: 22px; padding-right: 15px; margin-right: 15px;">

</div>

<div id="notifier" style="font-family: 'Times New Roman', Times, serif; font-size: large; font-weight: bold; text-transform: capitalize; width: 46px; height: 22px; padding-right: 15px; margin-right: 15px;">

</div>


I think this code useful to you
if you like help to other in searching ...............Thanks All

 

No comments