1
我有這個html頁面。在Chrome,如果我點擊Button2的幾個時間,然後點擊導航後退按鈕爲什麼popstate不會在Firefox中觸發
<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>
我可以在控制檯中看到:
location: http://somedomain:8080/examples/bar.html, state: {"foo":"bar"}
如果我嘗試用Firefox我沒有什麼也看不見?我Firefow 13.0.1 測試煩了,如果我想使用HTML5歷史API