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.