Ajax with history.pushState and popstate - what do I do when popstate state property is null?

前端 未结 6 1037
遥遥无期
遥遥无期 2021-02-07 01:18

I\'m trying out the HTML5 history API with ajax loading of content.

I\'ve got a bunch of test pages connected by relative links. I have this JS, which handles clicks on

6条回答
  •  眼角桃花
    2021-02-07 01:55

    And Finally says:

    I'd have thought the browser would be happy to step back to an entry that was created by a normal request.

    I found an explanation of that strange browser's behavior here. The explanation is

    you should save the state when your site is loaded the first time and thereafter every time it changes state

    I tested this - it works.

    It means there is no need in loading your content based on window.location.

    I hope I don't mislead.

提交回复
热议问题