Categories
JavaScript Answers

How to go from one page to another page using JavaScript?

Spread the love

Sometimes, we want to go from one page to another page using JavaScript.

In this article, we’ll look at how to go from one page to another page using JavaScript.

How to go from one page to another page using JavaScript?

To go from one page to another page using JavaScript, we set the window.location.href property to the string with the URL we want to navigate to.

For instance, we write

window.location.href = "sample.html";

to set window.location.href to "sample.html" to navigate to sample.html.

Conclusion

To go from one page to another page using JavaScript, we set the window.location.href property to the string with the URL we want to navigate to.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *