我已阅读有关推/弹状态的所有Mozilla文档。我想我错过了让它成功的难题。 pushstate正在按预期更新地址栏。
但是如何让页面恢复?基本上我像这样使用pushState
window.history.pushState({page: formattedTitle}, item.title, formattedTitle);
但是我希望从popstate返回formattedTitle
,这样我就可以运行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));
});