I'm trying to create a single-page application.
To allow the user to share links from some specific part of the site, I'm simulating navigation by inserting entries in the browser history.
The problem is, when the user click in the browser's back button, javascript doesn't trigger again. Is possible force it?
I Found the answer in developer.mozilla.org. Just add a listener to 'popstate' event:
window.addEventListener('popstate', function(event) {
if (event.state) {
myFunction();
}
}, false);
"myFunction" will be executed every time the active history entry changes.
window.history.pushState("Object", "Title", myUrl +"search=something");