Javascript – Safari event doesn’t trigger from the back button

backjavascriptjqueryonloadsafari

I don't seem to be able to get the body onload="…" event to fire in Safari when the page is entered via the back button. It works fine in FF and IE. Is there a Javascript or jQuery solution?

Any help appreciated.

Best Answer

Try:

window.addEventListener("pageshow", function() {
  alert('page shown');
}, false);

For Opera browser, read this: http://samuli.hakoniemi.net/onload-issues-with-opera/