Firefox没有在前进时触发popstate事件

时间:2016-04-25 11:20:59

标签: javascript ajax firefox browser-history html5-history

使用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;
    ...
});

1 个答案:

答案 0 :(得分:0)

使用pushState唤醒它。

history.pushState({}, '');
window.onpopstate = function() {
    alert(1);
}; 
相关问题