dana
dana

Reputation: 5228

a (javascript) countdown that doesn't restart at page refresh?

i was wondering if there is any solution for implementing a javascript counter that doesn't reset at page refreshm but it continues counting until the set time passes.

What do you know about it?

thank you

Upvotes: 2

Views: 3438

Answers (3)

ArtBIT
ArtBIT

Reputation: 3999

You can use localStorage or cookies to store your current counter value. Here's an example: http://jsfiddle.net/ArtBIT/KsYE4/

Upvotes: 2

alex
alex

Reputation: 490657

You will need to store its state somewhere, either in a cookie or serverside.

On each page load, the code will need to check its state and adjust its countdown accordingly.

Upvotes: 2

Jan Hančič
Jan Hančič

Reputation: 53929

You could store the current countdown timer count in a cookie (you would do that every time the timer changes). And then when the page loads (or refreshes) check for the value of that cookie first, and if it is set use that value as the starting point of the countdown counter.

Upvotes: 3

Related Questions