To add a time delayed redirect with JavaScript, we call setTimeout
.
For instance, we write
setTimeout(() => {
window.location.href = "/blog";
}, 2000);
to call setTimeout
with a callback to redirect to the /blog
page after 2000 milliseconds.