-2

some friends help me to write the following code to reload page once time after 1 sec but it had syntax error where i did not know.can any one help me to edit?

window.addEventListener('load', () => {
if(!window.localStorage.getItem("reload")) setTimeout(() => {
    window.localStorage.setItem("reload", "true");
    window.location.reload();
}, 1000)
});
window.addEventListener('unload',()=>{
window.localStorage.removeItem("reload");
})

Thanks

Black
  • 11
  • 5

1 Answers1

0
window.addEventListener('load', () => {
    if(!window.sessionStorage.getItem("reload")) setTimeout(() => {
        window.sessionStorage.setItem("reload", "true");
        window.location.reload();
    }, 1000)
});
Omid Navy
  • 272
  • 2
  • 12