- If you want to simulate someone clicking on a link, use
location.href
.
- If you want to simulate an HTTP redirect, use
location.replace
.
For example:
// Similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");
// Similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
Information copied from this answer to a duplicate question