Javascript Time Counter not reset on refresh | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Javascript Time Counter not reset on refresh

How to make javascript time counter that can't reset on refresh/reload a page? What the best practice for it if I want to using on CBT/Test application?

8th Apr 2017, 8:13 AM
cahya dwiana sn
cahya dwiana sn - avatar
3 Answers
+ 5
In this case you can use localStorage to store counter just before unload using https://www.w3schools.com/jsref/event_onunload.asp And upon refresh you can again fetch the value from localStorage.
8th Apr 2017, 8:47 AM
Ashwani Kumar
Ashwani Kumar - avatar
+ 3
What do you mean by time counter ??
8th Apr 2017, 8:23 AM
Ashwani Kumar
Ashwani Kumar - avatar
0
Sorry if my question make you confuse, i mean is countdown timer. In example, if i have a test that limited to 10 minutes, during the test if user refreshing the page/browser, timer continues countdown from last value before user refreshing page (ex: when user refresh page after 5 minute, the counter will started from 5 minute, not from initial value/ 10 minute again)
8th Apr 2017, 8:44 AM
cahya dwiana sn
cahya dwiana sn - avatar