jQuery document ready not called in Firefox after going back a page
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?
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).
精彩评论