var elapsedSeconds = 0; function startCounter() { setInterval(function() { elapsedSeconds++; document.getElementById("elapsedSeconds").innerText = elapsedSeconds; }, 1000); } window.onload = function () { startCounter(); setTimeout(function () { window.location.reload(); }, 100); }