The above example uses the
window.location.assign method to simulate an HTTP redirect to
window.location.replace, because the latter method resets the current tab’s history, thereby disabling the back button.
You can also set the value of
window.location.href to your preferred target URL, which will simulate a link click:
window.location.href = `https://example.com`;