Excuse me, I want to ask how to make javascript countdown doesn't reset when page refresh??

thank you in advance

The scope of JavaScript code is per page so refreshing the page is like making the code start again - like switching it off and on again.

So if you want to persist some value - ie the state of your counter - then you will need to store it somewhere and load it up again when the page is loaded.

The counter needs to be per user of course otherwise everyone will get the same value! So one option could be a cookie and another could be to store it on a server somewhere but that depends what technologies you are using, is your user signed in etc.

Reading and writing cookies with JavaScript - http://www.w3schools.com/js/js_cookies.asp

Hope that helps.

Or load your pages dynamically via AJAX (plus HTML5 History API) in a container (div) and place the counter oustide this container.

Look at this demo. Audio player keeps on playing and URL changes while navigating between content. This library really rocks!

http://docs.spb-piksel.ru/demos/history/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.