Skip to content
Advertisement

How to make this timer start itself soon as page loads

How can this particular code work on page load itself and even on refresh of page timer value remains ticking only when click submit it stops?

I guess we need to store the timer on localStorage and destroy storage on click submit?

JavaScript
JavaScript

Advertisement

Answer

You need to set the variable in localStorage not just the name

I have commented out the calls since they do not work in StackSnippets

Just uncomment them when you copy to your server.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement