Anchors in JavaScript

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";

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324970781&siteId=291194637