Here's a complete (yet simple) example of redirecting after X seconds, while updating a counter div:
<html>_x000D_
<body>_x000D_
<div id="counter">5</div>_x000D_
<script>_x000D_
setInterval(function() {_x000D_
var div = document.querySelector("#counter");_x000D_
var count = div.textContent * 1 - 1;_x000D_
div.textContent = count;_x000D_
if (count <= 0) {_x000D_
window.location.replace("https://example.com");_x000D_
}_x000D_
}, 1000);_x000D_
</script>_x000D_
</body>_x000D_
</html>
_x000D_
The initial content of the counter
div is the number of seconds to wait.