Javascript 为什么popstate不';不要在Firefox中开火
我有这个html页面。在chrome上,如果我在按钮2中多次单击,然后单击导航器返回按钮Javascript 为什么popstate不';不要在Firefox中开火,javascript,html,firefox,browser-history,Javascript,Html,Firefox,Browser History,我有这个html页面。在chrome上,如果我在按钮2中多次单击,然后单击导航器返回按钮 <html> <head> <script> function button_onclick(){ var stateObj = { foo: "bar" }; history.pushState(stateObj, "page 2", "bar.html"); } function onPopState(){ console.log("loc
<html>
<head>
<script>
function button_onclick(){
var stateObj = { foo: "bar" };
history.pushState(stateObj, "page 2", "bar.html");
}
function onPopState(){
console.log("location: " + document.location + ", state: " + JSON.stringify(event.state));
}
window.addEventListener('popstate', onPopState, false);
</script>
</head>
<body>
<button type="button" onclick="button_onclick()">Button 2</button>
</body>
</html>
如果我尝试Firefox,我什么都看不到?我用Firefow 13.0.1进行了测试
如果我想使用html5 history API管理历史记录,那真是太烦人了。在另一个问题上找到并帮助我: 单击链接时不应调用popstate。它是 当用户使用后退/前进按钮导航时调用 一切都按预期的方式运转
location: http://somedomain:8080/examples/bar.html, state: {"foo":"bar"}