HistoryState (demo)

add/replace history entries current history entry



This is a demonstration of a javascript library that provides a way to manipulate the browser's history stack for a single-page web application. It also provides a way to store variables unique to each instance of the page that can be accessed when the page is revisited as a result of clicking the "Back" or "Forward" button on an external site.

Unlike other history libraries, this script allows unique identification of every history entry, even if the same URL fragment is used twice in a single instance of the page. This eliminates the need to add a "counter" to the URL fragment so that each URL fragment will be unique.

In addition, this script allows stored session variables to be accessed instantly, even in Internet Explorer. Scripts running in the <head> tag can access session variables without waiting for the document's onload event to fire.

Currently, support for Internet Explorer ≥6, Firefox ≥1.5, and Safari ≥2.0.4 (including Safari 3 on Mac) has been implemented. I plan to add support for Opera 9 in the near future.


© 2006–2007 dbloom