I’ve set up a page where I’m using the following code so when you click on a link the content and URL changes without refreshing:
window.history.pushState("object or string", "title", "/photo.php");
But when a user clicks on the back button the content doesn’t change back. How to detect the back button?
You can use
onpopstate, like this. It will be fired when the navigation buttons are used, too.http://jsfiddle.net/54LfW/4/