History.js not firing after the initial browser window load

    $(function(){

        // Prepare
        var History = window.History; // Note: We are using a capital H instead of a lower h
        if ( !History.enabled ) {
             // History.js is disabled for this browser.
             // This is because we can optionally choose to support HTML4 browsers or not.
            return false;
        }

        // Bind to StateChange Event
        History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
            var State = History.getState(); // Note: We are using History.getState() instead of event.state
            History.log(State.data, State.title, State.url);
        });
});

I'm trying use history.js as a way to track state changes (forward and backward buttons) and it seems that the window.statechange is being fired ONLY when I open a new browser window and work from there. The initial forward and backward event is recorded but subsequent events are not.

Any ideas why that's happening?

Answers


I realize this question is very old. The solution is to move the statechange function outside of the body load function:

// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
    var State = History.getState(); // Note: We are using History.getState() instead of event.state
    History.log(State.data, State.title, State.url);
});

$(function(){

    // Prepare
    var History = window.History; // Note: We are using a capital H instead of a lower h
    if ( !History.enabled ) {
         // History.js is disabled for this browser.
         // This is because we can optionally choose to support HTML4 browsers or not.
        return false;
    }

});

Need Your Help

PHP - MultiProcessing(Using different cores)

php multiprocessing

I am writing a Cron in PHP which is supposed to run every hour and it is supposed to convert the last 10 videos in a directory to mp4 format.

converting NDB Datetimeproperty to date

python google-app-engine datetime app-engine-ndb

I have a NDB datetime property stored on Google App Engine. I'm trying to query for all records since yesterday by converting the datetime to a date, then filtering the query for anything greater or

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.