Firefox не запускает событие popstate при пересылке

Работа на ajax-страницах с History API. И застрял в точке, где Firefox не запускает событие «popstate»:

Вот поток посещений (URL):

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

person Vin.AI    schedule 25.04.2016    source источник
comment
stackoverflow.com/questions/14112341 /   -  person Manish Jangir    schedule 25.04.2016
comment
@ManishJangir Итак, согласно этому вопросу. Firefox не запускает и не будет запускать popstate при переходе вперед/назад после перезагрузки страницы.   -  person Vin.AI    schedule 26.04.2016


Ответы (1)


Используйте pushState, чтобы разбудить его.

history.pushState({}, '');
window.onpopstate = function() {
    alert(1);
}; 
person Gary Yeung    schedule 29.03.2018