JavaScript can implement page jump and redirection using the following two methods:
window.location.replace("url")
Similar to HTTP redirect
Replace the address with a new URL. This method replaces the current item cached in history (client-side) with the specified URL. Therefore, after using the replace method, you cannot access the replaced URL via "Forward" and "Back". This feature is very useful for making transition pages!
window.location.href="url.html"
Similar to clicking a link of an a tag。
Jump to the specified URL.
Example
Example
// Similar to HTTP redirect to Example
window.location.replace("https://www.example.com");
// Similar to clicking the Example link (a tag)
window.location.href = "https://www.example.com";
window.location.replace("https://www.example.com");
// Similar to clicking the Example link (a tag)
window.location.href = "https://www.example.com";