Jump to content

count down clock.


beansandsausages

Recommended Posts

hi i have a query.

 

i have a simple count down clock in javascript, counts down from 60min to 0min, but each time i leave the page and go back to it or refresh the page it starts from 60min again, how would i get it to remember the time and not start from 60min again?

 

Sorry its not in java script topic, i couldnt decide it if was a java problem or ajax.

Link to comment
https://forums.phpfreaks.com/topic/136351-count-down-clock/
Share on other sites

Notice you moved the topic. Sorry :(

 

where would i add the cookie to? this is the code:

 


<div id="countdown"></div>
<div id="notifier"></div>

<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 = '<?php echo " hi "; ?>';
    	clearInterval(this.ii);
    }
    
}
TDisplay = new _TDisplay();
_TDisplay.prototype.tick = function() {
TDisplay._tick.call(TDisplay);
}



//otherwise
pre = (window.onload) ? window.onload : function () {};
window.onload = function () {
pre();
TDisplay.init(3, document.getElementById('countdown'), document.getElementById('notifier'));
}

</script>

Link to comment
https://forums.phpfreaks.com/topic/136351-count-down-clock/#findComment-711349
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.