使用window.history.pushState使用popstate“后退”按钮调用Ajax

时间:2016-09-15 03:26:47

标签: javascript jquery ajax pushstate popstate

在用户导航的程序中,他们希望window.history.pushState生成的历史记录能够在浏览器中使用他们的后退按钮(因为无论出于何种原因他们不会单击应用程序中的后退按钮)

window.history.pushState({"html":'Visited Page',"pageTitle":'Page Title'},"",'http://exampleurl.com/item/');

要抓住他们按下后退按钮,我只需使用:

$(window).on("popstate", function(e) {
    // history.go(-1); 
    /* As you can see this was an attempt to make it work it only goes back to the last actual page visit */
});

如何将历史记录中的最后一个URL添加到window.location并将其发送到那里,或者更好的是如何让浏览器尊重推送的历史记录?

或者无论如何都要获得URL。

0 个答案:

没有答案
相关问题