2

我已经阅读了所有关于推送/弹出状态的 Mozilla 文档。我认为我错过了让它发挥作用的重要部分。pushstate 正在按预期更新地址栏。

但是如何找回页面呢?基本上我像这样使用pushState

window.history.pushState({page: formattedTitle}, item.title, formattedTitle);

但后来我想formattedTitle从 popstate 回来,这样我就可以运行getDetail(formattedTitle)函数了。但这不起作用。

$(window).bind('popstate', function(event){

        getDetail(JSON.stringify(event.state)) <- I want this to be getDetail(formattedTitle)
        console.log(JSON.stringify(event.state));
    });
4

0 回答 0