Use the <a name=> tag to define anchors, for example:
Define an anchor named top at the top of the document, which can be called as follows:
window.location.hash="#top";
In this way, the user can return to the previous location through the back button, but it is easy to disrupt the user's browsing history. You can use Location.replace() instead:
window.location.replace="#top";