0
值这里是我的代码:的Javascript历史不能检索onpopstate
function pushState() {
...snip... (SelectedMenuID has a value of 8)
var stateObj = { selectedMenu: SelectedMenuID };
history.pushState(stateObj, "The title to use", path);
}
window.onpopstate = function(event) {
if (event.state != null) {
alert(event.state.selectedMenu);
}
};
两个问题:
- 每一页上点击进入更新导航栏URL不错,但不更新标题为
the title to use
,因为我期望它 - 按回来创建警报,但值是
undefined
而不是8
正如我所期望的
“.pushState()”的“title”参数被Firefox忽略,也可能是其他浏览器。 – Pointy 2012-03-30 15:39:36
'event.state.selectedMenu'对我来说在Chrome中工作正常 – Esailija 2012-03-30 15:39:56
@Pointy我使用的是Chrome,希望它像Chrome网上应用店一样工作https://chrome.google.com/webstore/category/app/8 -教育 – 2012-03-30 15:43:44