codingtcher.com
Theme Night
Home
Login

Redirect to another page in javascript

//JS redirect
window.location.href = "/"; // appears on history
window.location.replace("/"); // does not appear on history

//redirect javascript
// 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";

Related Code