I wanted the page to refresh after 1 second and that's it, but after 1 second I get an infinite page refresh. How to fix endless page refresh?
function sayHi() {
document.location.reload();
return false;
}
setTimeout(sayHi, 1000);
<div class="timer">
Infinity refresh =(
</div>
When you reload the page, it's going to run the setTimeout again. You can use sessionStorage to make sure you refresh once per session.
if(!sessionStorage.getItem('refreshed')) {
sessionStorage.setItem('refreshed', true);
setTimeout(sayHi, 1000);
}