Ajax and back button. Hash changes, but where is previous page state stored?

前端 未结 2 1967
梦毁少年i
梦毁少年i 2021-02-07 22:43

I am trying to make ajax work with the back button and am missing something central. Where are the previous page states stored?

CASE 1:

Click \"make me re

2条回答
  •  耶瑟儿~
    2021-02-07 23:33

    When using AJAX it's important to update the history manually using history.pushState

    Then create a function testing for an onpopstate event and updating the content as required.

    https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_history

提交回复
热议问题