JavaScript
Article
By Kevin Yank

Bookmarks and back button history for AJAX apps

By Kevin Yank

Aside from the accessibility concerns, which are indeed serious, the biggest problem with single-page AJAX applications (Web apps that work largely or entirely within a single page, like GMail) is that the standard navigation tools provided by Web browsers — bookmarks/favourites and the Back/Forward buttons — become totally useless.

Now, from the same clever monkey developing the AMASS client-side data storage system I mentioned previously, comes a very promising partial solution to these issues.

Really Simple History is a script that lets you associate page anchor names with application states (e.g. page.html#state). The script works by linking the user to a new anchor whenever the application enters a new state (e.g. editing a blog entry). The script then watches the current URL for changes to the current anchor (due to back/forward navigation), and triggers a function you specify so that you can update the application state accordingly.

--ADVERTISEMENT--

Obviously it’s not quite as simple as I make out, but with the library in place, the code you need to write to support this is actually surprisingly simple. For now, Safari isn’t supported, but looking at how it works, I wouldn’t be surprised to see that browser supported before long.

The script’s site shows all the sample code you’ll need to get started if you’re a JavaScript gun. Less seasoned developers will want to check out the script author’s article on the O’Reilly Network.

Hopefully the large AJAX Web applications like GMail will lead the way by adding this to their offerings quick-smart. Now that proper bookmarking and navigation is now possible within single-page AJAX apps, I wouldn’t object quite as strongly to the notion of developing my next Web application ths way.

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account