3

Here is a very simple piece of jQuery code:

$(document).ready(function() {
  alert('document ready was called');
});

On Firefox (I have tested versions 5 & 6), this code is not executed if you load the page, go to another page on the same site, and then go back to that page - it is only loaded if you refresh the page.

Is there a way to force the JavaScript to load on back/forward navigation? Perhaps via forcing no caching? If so, what would be the performance implications?

mgeraci
  • 33
  • 1
  • 3
  • possible duplicate of [Why does Firefox 5 ignore document.ready?](http://stackoverflow.com/questions/6811929/why-does-firefox-5-ignore-document-ready) – Wladimir Palant Aug 22 '11 at 19:44

1 Answers1

1

That's because Firefox doesn't reload the page - it is restored exactly as it was when you left it, with all the dynamic changes and JavaScript variables still intact. Normally, there shouldn't be any reason to run additional code when this happens. However, if you still need it, there is a pageshow event that you can listen to. Additional information: https://developer.mozilla.org/En/Using_Firefox_1.5_caching (yes, this feature is that old).

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126