How does JS return to the previous page with intra-page navigation?

the reader I made has a directory made of a tag.
history.back (); returns to the location of the a tag that was positioned last time, rather than to the previous page.
how to return to the previous page with intra-page a tag navigation?

is either a fixed url, or returns the last accessed file. For example, a user enters page B from an unknown A page, visits B-sharptitle and BMel sharpcontent in page B, and now wants to click the button to return to An instead of B-sharptitle.

I thought that every time I clicked on the a tag, I counted + 1, and finally hisotry.go (- num),), but it felt so troublesome that every a tag had to write an onclick. Is there a simpler way?

Aug.18,2021

directly

window.location.href = document.referrer

does this meet the requirements?


as , so that the previous url of this page will not be recorded in history, and then use history.back (); to return to the previous interface

.
Menu