Sometimes, we want to change the location of the current web page using JavaScript.
In this article, we’ll look at how to change the location of the current web page using JavaScript.
How to change the location of the current web page using JavaScript?
To change the location of the current web page using JavaScript, we set window.location.href
to the URL we want to go to.
For instance, we write
window.location.href = 'URL';
to set window.location.href
to the string with the URL we want to navigate to.
Conclusion
To change the location of the current web page using JavaScript, we set window.location.href
to the URL we want to go to.