Вопрос

I'm using history.js to manipulate the HTML5 browser history API, and everything works as expected except when the page is refreshed.

When the page is initially loaded by the browser, the statechange event is fired thus triggering my custom statechange logic. However, this event is not fired when the page is refreshed by the user (e.g., presses F5 or clicks the reload button in their browser).

Is there any way to force a statechange even when the browser is refreshed, or am I looking at this problem all wrong.

Это было полезно?

Решение

I couldn't figure out what was causing the issue, but this little code "fixed" the issue

$(function()
{
    if (History.getCurrentIndex() == 0)
    {
         History.Adapter.trigger(window, 'statechange');
    }
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top