The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features

See the new Forums

Javacript window.onload

Forums » Dev.Opera » General Web Development Discussions

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

1. December 2011, 11:12:53

harryalffa

Posts: 2

Javacript window.onload

Please feel free to shoot me down, but I've searched here and found nothing useful.

This must be a problem encountered before: The browser "back" button doesn't activate the window.onload event.

How do I get my Javascript function to be called in Opera (and Chrome) when my page is accessed by the user hitting the "back" button? Please note I also have a window.onunload function. The Javascript works when the "refresh" button is hit. Note also both functions (.onload, .onunload)) work in FF and IE.

I want to avoid jQuery.

Cheers.

3. December 2011, 19:02:18

greench

Posts: 4825

I'm not certain but you can check HTML5 History API.
Sorularınızı sorabileceğiniz yeni adresimiz Opera Türkiye Forum

4. December 2011, 20:22:51

spadija

Posts: 1643

See Opera's support page on history navigation for an explanation as to why this is happening. In short, when you go back a page, Opera simply restores the page exactly as it was when you left it. The page does not get reloaded, so window.onload doesn't get called.

If you absolutely need to override this, setting window.navigationMode to 'compatible' should force Opera to reload the page from cache instead of restoring it as it was.

Forums » Dev.Opera » General Web Development Discussions