Thursday, September 22nd, 2005

Ajax and Browser History

Category: Articles, Dojo

Brad Neuberg has gone off experimenting with the combination of Ajaxian techniques, and the browser history (back and forward).

Issues

The following major issues affect all of the AJAX history libraries I have evaluated, other than the Really Simple History framework.

First, some history frameworks, such as Dojo, use JavaScript objects to store an internal representation of the state of an AJAX application’s history; unfortunately, browsers completely clear out all JavaScript objects when a user leaves a page. If a user interacts with an AJAX application, navigates to Google, and then returns to their original AJAX page, the AJAX history framework’s internal state is erased and becomes confused.

Another bug that affects many frameworks is that they do not differentiate between the first time a page truly loads versus “fake” page loads. In many browsers, when a user first loads an AJAX application, the browser will throw an onload event. Later, if the user navigates to a different web site and then returns using the back button, the browser will throw a new onload event even though the page already loaded the first time. Many subtle bugs can occur in AJAX history frameworks unless these two kinds of load events are differentiated.

Download Brad’s Really Simple History framework.

Resources

Fixing the Back Button and Enabling Bookmarking for AJAX Apps

Erik Arvidsson’s Hash Listener library

Dojo docs for dojo.io.bind() and back/forwardButton:

Posted by Dion Almaer at 3:59 pm
1 Comment

+++--
3.6 rating from 28 votes

1 Comment »

Comments feed

Other alternatives include jQuery History which provides nice tracking of hash changes for your website. And jQuery Ajaxy which allows you to have a rich ajax website while still supporting the back and forward buttons and no server side changes.

jQuery History: http://www.balupton.com/projects/jquery-history
jQuery Ajaxy: http://www.balupton.com/projects/jquery-ajaxy

Comment by balupton — August 28, 2010

Leave a comment

You must be logged in to post a comment.