Why do you jump to the local a.html page facing the b.html page when you get it?

Why do you bind
window.addEventListener ("popstate", function (ev) {

) to
b.html when the local a.html page is directed to the b.html page?
alert(1)

})
back to an after the b page, why didn"t 1 pop up

Nov.03,2021

Brother, are you bound to this event on your A page? If you jump to the A page again, it is another interpretation of the team A page code, and of course you can't pop up without the relevant code. Upstairs said the incident will not be triggered, this has never been used. But basically can not escape these aspects.


calling history.pushState () or history.replaceState () does not trigger the popstate event. This event is triggered only when a browser action is made, such as when the user clicks the browser's fallback button (or calls history.back () in the Javascript code).
triggering popstate events is generally used in the case of a single page and changing URL without refresh. If you want to listen, you can use window.location.href to change hash only or use location.hash directly. You can also use H5 to add API history , such as history.pushState ({}, document.title,'/ b.html')

.
Menu