Use either location.href or location.replace:
// Simulate a mouse click:
window.location.href = "https://www.niceonecode.com";
// Simulate an HTTP redirect:
window.location.replace("https://www.niceonecode.com");
replace() removes the URL of the current document from the document history, it means that it is not possible to use the "back" button to navigate back to the original page.
Posted On:
06-Jan-2021 07:01