Categories
JavaScript Answers

How to redirect to the home page with JavaScript?

Spread the love

Sometimes, we want to redirect to the home page with JavaScript.

In this article, we’ll look at how to redirect to the home page with JavaScript.

How to redirect to the home page with JavaScript?

To redirect to the home page with JavaScript, we set window.location.href to '/'.

For instance, we write

window.location.href = "/";

to redirect to the home page by setting window.location.href to '/'.

Conclusion

To redirect to the home page with JavaScript, we set window.location.href to '/'.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.