Jump to content

count down clock.


burnside

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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.