Remembering Place

In the last of the slideshows, which contains "pages" of links to existing weblog posts, clicking one of the links loads that story into the browser. Well and good, but if you click one of the links, another page opens in the browser. When you're ready to go back to the list, depending on the browser, the "place" where you had left the original slideshow is lost, and the first page is opened. If you open another page by typing in a new URL, using a search engine toolbar, or clicking a link in the bookmarks list, when you attempt to use the Back button to return to the slideshow application, again, you'll lose your "place."

A second problem is associated with trying to create a permanent link to a specific page in the slideshow, for instance, if you want to link to the fifth page in the text slideshow, or link to the third photo. The most you can do, with the way the application is currently coded, is tell users to go to the first page and then click the Next button so many times. This really isn't a workable option. What we need is a way to remember place.

Remembering Place and Page Fragments

Remembering place and persisting place are two problems with Ajax slideshows or any other single-page application. The way around both of these challenges is through the use of the window.location object, and the use of a page fragment, called the hash. A page hash is a value that's tacked on to the end of a URL when a page fragment is accessed within a page. Page fragments are ...

Get Adding Ajax now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.