Can I prevent history.popstate from triggering on initial page-load?

前端 未结 5 1915
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 22:43

I\'m working on a site that serves content via AJAX.

If you click an item in the menu, a content div gets updated with $.get response, nothing fancy.

5条回答
  •  情歌与酒
    2020-11-30 23:20

    I use the below approach to change the address bar and save the current state including the current HTML body, and I reload it on the back button click without any other AJAX call. All gets saved in your browser:

    
    

提交回复
热议问题