hey,
so you want a normal site that doesn't reload unless someone clicks a button and then it should reload every 5 seconds?
you could use localStorage to check whether to reload every 5 seconds or not. here is a small example:
<divid="counter"></div><buttonid="start-counter">start reloading after every 5 seconds</button><buttonid="stop-counter">stop reloading after every 5 seconds</button><script>letreloadTimeout=null;conststartReloading=()=>(reloadTimeout=setTimeout(()=>window.location.reload(),5000));constcounterElement=document.getElementById("counter");conststartCounterElement=document.getElementById("start-counter");conststopCounterElement=document.getElementById("stop-counter");startCounterElement.addEventListener("click",()=>{localStorage.reloadActive=true;startReloading();});stopCounterElement.addEventListener("click",()=>{localStorage.reloadActive=false;clearTimeout(reloadTimeout);});letcounter=0;window.addEventListener("load",(event)=>{if(localStorage.reloadActive==="true"){startReloading();}});setInterval(()=>{counterElement.innerHTML=counter++;},1000);</script>
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
hey,
so you want a normal site that doesn't reload unless someone clicks a button and then it should reload every 5 seconds?
you could use localStorage to check whether to reload every 5 seconds or not. here is a small example: