onload and onunload events do not fire when going back, forward or refreshing the page
Browser
Opera
Example
Any code using onload or onunload, e.g.
Expand|Select|Wrap|Line Numbers
- window.onload = init;
Solution
There is no solution because according to Opera developers and users this is not a bug. Opera maintains the runstate of scripts, so it's as if we never left the page when we return back to it. According to Opera, onload should only fire when loading the page for the first time and onunload should fire when unloading the page completely, not when just leaving the page by pressing the back, forward or refresh button. Refresh is considered to be a reload, not an unload.
This should be something you should be mindful of when depending on onload and onunload in your code.
Obviously, if onunload does not fire, onbeforeunload (which is a non-standard event supported by some browsers) will not work either.
More Bugs, Quirks and Inconsistencies