Reputation: 3
Hello I'm using the jQuery countdown from Keith Wood (http://keith-wood.name) and I would like to know how I keep the counter going when someone refreshes the page. So every time someone enters the page he must see the countdown going
I'm a complete newbie with jQuery. I make use of the jquery.countdown.min.js file.
Here is the JS Fiddle http://jsfiddle.net/wthf9/2/
jQuery(document).ready(function($){
jQuery('#offline-countdown').countdown({
until:'+1d, 1h, 3h, 3m, 1s',
format: 'DHMS',
labels: ['Years','Months','Weeks','Days','Hours','Minutes','Seconds']
});
});
Thanks a lot if someone can help me!
UPDATE!
You can find here the answer if someone need:
Upvotes: 0
Views: 471
Reputation: 8103
This will ensure that the countdown "persists" across page refreshes.
The reason this works w/o cookies or local storage is because the time is fixed, so when the page is refreshed a new time is calculated on the fly giving the appearance of state.
$(function(){
var newYear = new Date();
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);
$('#offline-countdown').countdown({until: newYear});
});
Here's an example of it in action. (Try refreshing the page with this fiddle)
Sidenote: $(function() { });
is the same thing as $(document).ready(function() { });
Upvotes: 1