Search code examples
jquerycountercountdown

count down that does not reset on page refresh


I found this count down timer code here http://jsfiddle.net/QH6X8/ I would like to make 3 additions if possible.

  1. How can I make it so that the count down does not reset and start all over if the visitor reloads the page.

  2. In the code it has var end = new Date('15 Jul 2011'); How can I make it so that it is counting down to a specific hour instead of day(s) like this var end = new Date('15 Jul 2011 1:00 PM PDT');

  3. Lastly after the count down is finished I would like it to display some text Your time is up!.


Solution

  • For the first, use cookies. A full tutorial can be found here.

    For the second: var end = new Date('15 Jul 2011 1:00 PM PDT');

    Well it already looks like you know how to use setInterval, so, instead of continuing to modify the timer, use document.getElementById('countdown').innerHTML = "Your time is up" So that takes care of 3.