Reputation: 83
I am using Keith Wood Jquery Countdown Timer (http://keith-wood.name/countdown.html) and I wanted to make it so that when the timer hits 0 the page would refresh. unfortunately I couldn't make this happen.. Here is my code:
$(function () {
var now = new Date($.now());
var austDay = new Date();
austDay = new Date(//php stuff to get the date from the database..);
$('#defaultCountdown').countdown({until: austDay, format: 'DHMS'});
if (austDay <= now) {
location.reload();
}
});
Thanks in advance.
Upvotes: 0
Views: 1007
Reputation: 21881
From the documentation
onExpiry: A callback function that is invoked when the countdown reaches zero. Within the function this refers to the division that holds the widget. No parameters are passed in. Use the expiryText or expiryUrl settings for basic functionality on expiry.
$(selector).countdown({
until: liftoffTime, onExpiry: liftOff});
function liftOff() {
alert('We have lift off!');
}
Upvotes: 1
Reputation: 150010
According to the documentation that you linked to, you can specify an onExpiry
callback for when the countdown gets to zero. You then supply a function that can do whatever you like at that moment:
$('#defaultCountdown').countdown({
until: austDay,
format: 'DHMS',
onExpiry: function() { location.reload(); }
});
(I haven't tested the above code, but it seems pretty clear in the doco.)
Upvotes: 3