How to “browser back” when using pushState?

前端 未结 2 1195
终归单人心
终归单人心 2021-01-16 06:06

I have this code:

window.history.pushState(newUrl, \"\", newUrl);

My question is, how to make sure that when doing pushState the browser ba

2条回答
  •  不知归路
    2021-01-16 06:28

    push is for pushing... adding


    you should go for history.back()

    If you want to popState - emit popstate event on window or do history.replaceState()


    If you want to cancell commented event: My answer will do the trick https://stackoverflow.com/a/44553087/5694206

提交回复
热议问题