window.location.replace(...) is better than using window.location.href, because replace() does not keep the originating page in the session history, meaning the user will not have a chance in never-ending back-button fiasco.

In a nutshell:

To simulate someone clicking on a link, use window.location.href.

// similar behavior as clicking on a link
window.location.href = "https://www.cloudberry.com.my";

To simulate an HTTP redirect, use window.location.replace.

// similar behavior as an HTTP redirect
window.location.replace("https://www.cloudberry.com.my");

References:
MDN Web Docs – Window.location

Last modified: January 13, 2018

Author