Redirect a URL using Javascript

We can use window.location.replace(…) or window.location.href to redirect a URL using JavaScript.

//Behave as an HTTP redirect
window.location.replace("https://www.w3schools.blog");

//Behave as clicking on a link
window.location.href = "https://www.w3schools.blog";
Related topics: