1// similar behavior as an HTTP redirect
2window.location.replace("http://stackoverflow.com");
3
4// similar behavior as clicking on a link
5window.location.href = "http://stackoverflow.com";
1<script>
2 window.location.href = "http://mywebsite.com/home.html";
3</script>
1// removes the link from the history,
2// e.g. if you would click the arrow back in any browser
3// user wouldn't return to that site
4window.location.replace("http://stackoverflow.com");
5
6// similar behavior as clicking on a link
7// user will return to that site if pressing arrow back
8window.location.href = "http://stackoverflow.com";
9
1<p onclick="myFunction()"></p>
2<script>
3function myFunction() {
4 window.location.href = "https://whereyouwouldliketogo.com"
5}
6</script>