For all major browsers (except IE), the JavaScript onload event doesn’t fire when the page loads as a result of a back button operation — it only fires when the page is first loaded.
Can someone point me at some sample cross-browser code (Firefox, Opera, Safari, IE, …) that solves this problem? I’m familiar with Firefox’s pageshow event but unfortunately neither Opera nor Safari implement this.
Guys, I found that JQuery has only one effect: the page is reloaded when the back button is pressed. This has nothing to do with ‘ready‘.
How does this work? Well, JQuery adds an onunload event listener.
By default, it does nothing. But somehow this seems to trigger a reload in Safari, Opera and Mozilla — no matter what the event handler contains.
[edit(Nickolay): here’s why it works that way: webkit.org, developer.mozilla.org. Please read those articles (or my summary in a separate answer below) and consider whether you really need to do this and make your page load slower for your users.]
Can’t believe it? Try this:
You will see similar results when using JQuery.
You may want to compare to this one without onunload