I'm currently experiencing an issue with the back navigation button on my one-page website. When I load a new page, I use the following code snippet:
displayPage = function (page, json) {
var stateObj = { "page": page, 'json': json };
history.pushState(stateObj, "", page);
// some code here
and then when the back button is triggered:
$(function() {
Skeleton._construct();
window.onpopstate = function(event) {
Skeleton.dispPage(event.state);
}
});
this.dispPage = function(blob){
displayPage(blob.page, blob.json);
}
However, after clicking the back button once, the onpopstate event is triggered and I successfully go back to the previous page. But if I click the back button again, or multiple times, the onpopstate event is no longer triggered. Can anyone advise me on what I should do in this situation?
Thank you in advance for your help.