jQuery倒计时,不重置 [英] jQuery Countdown that dont reset
问题描述
您好,我正在使用Keith Wood的jQuery倒数计时( http://keith-wood.name )并且我想知道当有人刷新页面时如何保持计数器运行.因此,每次有人进入页面时,他都必须看到倒数计时
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
我是jQuery的新手.我利用了jquery.countdown.min.js文件.
I'm a complete newbie with jQuery. I make use of the jquery.countdown.min.js file.
这是JS小提琴 http://jsfiddle.net/wthf9/2/ >
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!
更新!
如果有人需要,您可以在这里找到答案
You can find here the answer if someone need:
推荐答案
这将确保倒数计时在整个页面上持续"刷新.
This will ensure that the countdown "persists" across page refreshes.
之所以无法使用Cookie或本地存储,是因为时间是固定的,因此刷新页面时会实时计算出一个新的时间,以显示状态.
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)
旁注:$(function() { });
与$(document).ready(function() { });
这篇关于jQuery倒计时,不重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!