Article

Simulate a mouse click

window.location.href = "/";

Simulate an HTTP redirect

window.location.replace("/");

Example:

function redirectToHome() {
  alert("This is a restriced page and you are not logged in. Please login from the homepage");

  window.location.href = "/";
}