0

For my website I have an option to filter, which updates the url. The url contains the filter parameters. If the page loads checkboxes will be checked if they are in the url. The functions works well if I go to the url. But if I press back to go to the last page (read last filter options) the function wont run. The function is called:

setBoxes();

I tryed:

function pageLoad() {
   setBoxes();
}

And

$(document).ready(function(){
   setBoxes();
}

Also I added

 window.onunload = function(){};

As suggested at After travelling back in Firefox history, JavaScript won't run

What should I try next?

Community
  • 1
  • 1
Sven van den Boogaart
  • 11,833
  • 21
  • 86
  • 169

1 Answers1

0

It's browser cache. You can use pushstate to indicate "back" event in browser.

See history.js https://github.com/browserstate/history.js/

// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
    var State = History.getState(); // Note: We are using History.getState() instead of event.state
});
maxwp
  • 83
  • 1
  • 6