Tip 30Preserving History

The HTML5 specification introduces an API to manage browser history.[73] With it, we can add entries into the history, replace entries, and even store data, which we can retrieve when we revisit the page. This is great for single-page applications where things update dynamically but you still want to allow the user to use the Back button.

In Tip 15, Creating an Accessible Updatable Region, we built a prototype for AwesomeCo’s new home page that switched out the main content when we clicked one of the navigation tabs. One drawback with the approach we used is that there’s no support for the browser’s Back button. If we click a tab, pressing the Back button in the browser takes us to the previous web page we visited, ...

Get HTML5 and CSS3, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.