• Push — adds a new record to the history stack, and the user clicks the browser’s back button to return to the previous path;

  • Go — This method takes an integer, meaning how many steps forward or backward in the history record, like window.history.go(n), where n can be positive or negative;

  • GoBack — returns to the previous page, equivalent to window.history.go(-1);

  • Replace — Redirects to the specified URL by replacing the current history. This method does not add a new record to the history. The previous record does not exist;

[Note] Make sure to distinguish the use scenarios when jumping. (I’ve already skipped this one, so keep it in mind)

If there is a record that is not in history, use push to jump. If there is a record that is going to jump to the page, use go to return to the specified page. Do not push any more, otherwise, the return event may not proceed as expected. To replace the current page, use replace.

【 extension 1】

window.location.reload(); / / refresh

window.history.go(1); / / to go forward

window.history.go(-1); / / back

window.history.forward(); / / to go forward

window.history.back(); // Back + refresh

【 extension 2】 The difference between history. Back and history. Go:

History. Back (1); // Returns the previous page of the current page directly, data full message, is a new page

History. Go (1); // Returns the previous page of the current page, but all the data in the form is still there