Sometimes, we want to auto refresh page every 30 seconds with JavaScript.
In this article, we’ll look at how to auto refresh page every 30 seconds with JavaScript.
How to auto refresh page every 30 seconds with JavaScript?
To auto refresh page every 30 seconds with JavaScript, we call setTimeout
with a callback that calls location.reload
.
For instance, we write
window.setTimeout(() => {
window.location.reload();
}, 30000);
to call setTimeout
with a callback that calls location.reload
after 30000 milliseconds or 30 seconds.
Conclusion
To auto refresh page every 30 seconds with JavaScript, we call setTimeout
with a callback that calls location.reload
.