Start New Discussion within our Web Development Community

A site I'm developing loads new pages via AJAX, to allow people to share the links we use a hashtag to track the URL E.G.
User is on
User clicks on link to
page2.html is loaded dynamically and the URL is set to!/page2.html
That all works fine, but now when the user presses the 'Back' button in their browser the URL changes to but the page stays the same. Is there any way to do something similar to

document.onBackButton = function() {
   //Check hashtag and load new page
document.onForwardButton = function() {
   //Check hashtag and load new page


The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.