Join Bill Weinman for an in-depth discussion in this video Handling back and forward buttons with the popstate event, part of HTML5: Managing Browser History.
This is really just where we left off from our last lesson.…So here, you see in the init method we are pushing 10 items onto the history…stack, and now we want be able to step through those with the Back button and…get the value from them.…So if you remember, the first argument to this pushState method is a state object.…This state object is what we're going to read off of the stack.…So the state object in this case, it's just the integer from our loop, so it'll…be 0, 1, 2, 3, 4, 5, et cetera, on up to 9.…
So we're just going to go ahead in here and we're going to register an…EventHandler for the popstate event.…
- Manipulating browser history: an overview
- Detecting History API support
- Pushing a new URL onto the stack
- Handling back and forward buttons with the popstate event
- Updating the stack with replaceState()