samarudge 16 Posting Whiz

Hi,
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 example.com/page1.html
User clicks on link to example.com/page2.html
page2.html is loaded dynamically and the URL is set to example.com/page1.html#!/page2.html
That all works fine, but now when the user presses the 'Back' button in their browser the URL changes to example.com/page1.html 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
}

Thanks
-Sam

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.