Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

5. User Interactions > Hack 51. Take Control of the Browser History Buttons wit...

Hack 51. Take Control of the Browser History Buttons with HTML5 Session History

HTML5 provides an elegant way to programmatically control the history stack while in your web application.

How many times have you been inside a great web app, only to click the browser back button thinking it will undo your last navigation, but instead it takes you back to the last website? HTML5 session history gives you an easy interface for managing the history within your application.

In the past, developers have done tricky things to applications to enable them to “fool” the behavior of the browser history by using hash tags within the URL. Usually, the developer would add something like “#mynewurl” to the end of his page URL, and it would add a new position in the history stack. Anytime you add a “#” to a URL, it considers it a position within the page, and doesn’t leave the page when the back button is clicked.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint