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