Sometimes, we want to make a time delayed redirect with JavaScript.
In this article, we’ll look at how to make a time delayed redirect with JavaScript.
How to make a time delayed redirect with JavaScript?
To make a time delayed redirect with JavaScript, we call setTimeout
.
For instance, we write
setTimeout(() => {
location.href = "http://www.example.com";
}, 1500);
to call setTimeout
with a callback that sets location.href
to "http://www.example.com"
to redirect to http://www.example.com after 1500ms.
Conclusion
To make a time delayed redirect with JavaScript, we call setTimeout
.