1.11M Members

onBack/onForward

 
0
 

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

Isn't it about time forums rewarded their contributors?

Earn rewards points for helping others. Gain kudos. Cash out. Get better answers yourself.

It's as simple as contributing editorial or replying to discussions labeled or OP Kudos

You
This is an OP Kudos discussion and contributors may be rewarded
Post:
Start New Discussion
Tags Related to this Article