How to redirect to another web page using JavaScript
Learn how to redirect a web page’s visitors to another page using JavaScript in this quick and easy tutorial.
Redirecting to a web page on the same domain
To redirect a web page’s visitors to another page on the same domain:
window.location.pathname = "/new-page"
Redirecting to a web page on a different domain
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.
100% Mac, Windows
and Linux friendly!
and Linux friendly!
Click here to get started.
It’s fast, easy and secure.
It’s fast, easy and secure.
From $2.68/mo
We can help you move your
email and websites as desired.