Some browser(Opera) does not seem to catch onbeforeunload event.
It is better to use onload event than onbeforeload event.