I’m doing a counter to count how many people, for example, died from smoking. But I have a problem, the counter is reset when the pages are updated. The counter should be such that it would not start from the beginning after the page was reloaded and the same number should be displayed for all users who visited the site.
My code from codepen or
time100.init({
timenow:{zone:"Europe/Moscow",format:"%Y,%m,%d %H:%i:%s"}
});
window.onload = function () {
var time = document.getElementById('time').innerText;
var startValue = 0;
var startTime = (new Date(time)).getTime();
var inSec = 20;
value = startValue + Math.round(((new Date(time)).getTime() - startTime) / 1000 * inSec);
function add() {
value += inSec;
document.getElementById("count").innerHTML = value;
}
setInterval(add, 1000);
};
<span class="timenow" id="time" hidden></span>
<div style="float: left">Died from smoking: </div>
<div id="count"></div>
<script type="text/javascript" src="http://time100.ru/t.js"></script>