I have a regressive cot, but when the browser is updated it comes back to the beginning, what I need is for it to keep the count even updating the page.
I've been researching this solution with cookies but I did not find the solution, I do not want the answer given, I want to learn how it does, can someone give me a follow-up?
Note: If someone does not understand the problem, it is the same as this one .
function tempo(op) {
if (op == 1) {
document.getElementById('parar').style.display = "block";
document.getElementById('comeca').style.display = "none";
}
var s = 59;
var m = 1;
var h = 1;
intervalo = window.setInterval(function() {
if (s == 0) { m--; s = 59; }
if (m == 0) { h--; m = 0; }
if (h < 0) h = 0;
if (h < 10) document.getElementById("hora").innerHTML = "0" + h; else document.getElementById("hora").innerHTML = h;
if (s < 10) document.getElementById("segundo").innerHTML = "0" + s; else document.getElementById("segundo").innerHTML = s;
if (m < 10) document.getElementById("minuto").innerHTML = "0" + m; else document.getElementById("minuto").innerHTML = m;
s--;
if ((h == 0) && (m == 0) && (s == 0) ) m=59;
},1000);
}
window.onload=tempo;
body{ background: #20262E;}
/* CSS Contador */
.ContBoxContador{ width: 270px; margin: 0 auto; color: white; text-align: center; }
.ContBoxContador:after{ content: ""; display: table; clear: both; }
.ContBox001{ width: 80px; float: right; background-color: red; border-radius: 5px; }
.ContSubbox001{ width: 80px; }
.ContSubbox001 span{ font-size: 14pt; padding: 0; margin: 0;}
.ContSubText001{ font-size: 8pt; color: white; margin: 0; padding-bottom: 4px; font-weight: 500; font-family: open sans, sans-serif; }
.ContEntreBox{ width: 10px; float: right; margin: 0; padding: 0;}
.ContEntreBox h1{ font-size: 2em; color: white; font-weight: 100; margin: 0; padding: 0;}
<div class="timerBox">
<div class="ContBoxContador">
<div class="ContBox001">
<div class="ContSubbox001">
<span id="segundo">00</span>
</div>
<div class="ContSubbox001">
<h6 class="ContSubText001">Segundos</h6>
</div>
</div>
<div class="ContEntreBox"><h1>:</h1></div>
<div class="ContBox001">
<div class="ContSubbox001">
<span id="minuto">00</span>
</div>
<div class="ContSubbox001">
<h6 class="ContSubText001">Minutos</h6>
</div>
</div>
<div class="ContEntreBox"><h1>:</h1></div>
<div class="ContBox001">
<div class="ContSubbox001">
<span id="hora">00</span>
</div>
<div class="ContSubbox001">
<h6 class="ContSubText001">Horas</h6>
</div>
</div>
</div>
</div>