How to change the location of the current web page using JavaScript?

Spread the love

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 the window.location.href property.

For instance, we write

window.location.href = "URL";

to set window.location.href to the string with the URL we want to go to.

Conclusion

To change the location of the current web page using JavaScript, we set the window.location.href property.

Leave a Reply

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