Previous topic

Arrays and Dojo

Next topic

Browser Sniffing

This Page

Backbuttons and Dojo

Status:Draft
Version:1.0
Authors:Bill Keese, Nikolai Onken

Dynamic web applications that use things like XMLHTTPRequest and DOM updates instead of page refreshes do not update the browser history, and they do not change the URL of the page. That means if the user clicks the Back button, they will likely jump all the way out of the web application, losing any state that they were in. It is also hard to allow a user to bookmark the web application at a certain state.

Dojo’s dojo.back module introduces browser history so that it is possible for the user to click Back and Forward without leaving the web application, and the developer can get notification of these Back and Forward events and update the web application appropriately. Browser history is generated by using a hidden IFRAME and/or adding a unique value to the fragment identifier portion of the page URL. The fragment identifier is the #value thing in a URL. For example:

http://some.domain.com/my/path/to/page.html#fragmentIdentifier

Since changing the fragment identifier does not cause the page to refresh, it is ideal for maintaining the state of the application. The developer can specify a more meaningful value for the fragment identifier to allow bookmarking.

dojo.back allows setting a state object that represents the state of the page. This state object will get callbacks when the Back or Forward button is pressed.