Learn how to redirect a web page’s visitors to another page using JavaScript in this quick and easy tutorial.
To redirect a web page’s visitors to another page on the same domain:
window.location.pathname = "/new-page"
To redirect a web page’s visitors to a page on a different domain:
window.location.href = "https://www.example.com/page"
That’s all there is to it!
Love our articles? HostM offers professional and helpful web hosting services with unlimited features and renewal rates that actually match our advertised rates.
From $2.48/mo
We can help you move your
email and websites as desired.