Volkan.
10.24.2005
onunload and onbeforeunload compared
Some compatibility results for onbeforeunload:
Opera 8 -> *it does not work*
IE -> works okay
Moz -> works okay
Saf and the rest-> not tested
Here is what ppk says about Opera' onunload:
"In Opera load and unload do not fire when the user uses Back or Forward to enter or leave a page, or when the user closes the window."
... onload support of opera is similar. Again PPK says:
"Opera itself says this is the correct way to handle onload. Although this may be true, it will certainly cause compatibility problems. "
Here is another quote from someone else:
"IE4+/Win, Mozilla 1.7a+, Netscape 7.2+, and Firefox support onbeforeunload"
At least Safari fully supports onunload event. I am not sure whether it supports onbeforeunload, and if it does whether it supports it correctly.
Having seen that Opera does not have the memory leak problem at all, the onunload fix is basically for ie and moz. In short, I think I'll stick with onunload.
Or better use a switch like:
var g_bul_fired=false;
window.onbeforeunload=function(evt){
g_bul_fired=true;
... cleanup ...
};
window.onunload=function(evt){
if(!g_bul_fired){
... cleanup ...
}
};