这是我的代码:
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
我预期的不同