使用History API处理ajax页面。并且停留在Firefox没有触发“popstate”事件的地方:
以下是访问流程(网址):
1. Started from Home Page (/)
2. Visited About Us (/about-us)
3. Clicked Back Button to go on Home Page (/)
4. Refreshed the page using F5
5. Clicked Forward button to go on (/about-us) # Here firefox not firing "popstate" but Chrome is
剧本:
$(window).on("popstate", function (e) {
var data = window.history.state;
console.log("State Data:");
console.log(data);
popped_first = true;
...
});
答案 0 :(得分:0)
使用pushState唤醒它。
history.pushState({}, '');
window.onpopstate = function() {
alert(1);
};