weixin_33744141 2016-08-24 19:26 采纳率: 0%
浏览 11

历史回到了ajax

Is there a way to go back in history only for ajax calls ?

I'm looking for a history back button that only works for ajax calls on the current page.
So the button should not have the power to leave the page as we know it from browser back button.

  • 写回答

1条回答 默认 最新

  • weixin_33708432 2016-08-24 19:34
    关注

    You can use the History API for this.

    Basically what you are doing is calling history.pushState() when doing an AJAX call and listening for the popstate event on the window object. But the logic that will manipulate your DOM to show the last state will have to be implemented by yourself.

    评论

报告相同问题?