I found that I couldn''t register an unload event using prototype.
The reason seems to be that prototype registers an unload event which
unregisters all events, including other unload events. It''s commented
as
a fix for an IE memory leak.
In case anyone else wants to use unload events, here''s a fix that works
for me, and might work for you. It simply skips unload events when
unregistering. I don''t know whether this will cause memory problems in
IE, but I''m prepared to risk it until someone comes up with a better
solution.
$ diff -u prototype.js.1.4.0 prototype.js
--- prototype.js.1.4.0 2006-01-25 16:48:43.575591720 +0000
+++ prototype.js 2006-01-25 16:45:59.765494640 +0000
@@ -1511,8 +1511,10 @@
unloadCache: function() {
if (!Event.observers) return;
for (var i = 0; i < Event.observers.length; i++) {
- Event.stopObserving.apply(this, Event.observers[i]);
- Event.observers[i][0] = null;
+ if (!(Event.observers[i][1]=="unload")) {
+ Event.stopObserving.apply(this, Event.observers[i]);
+ Event.observers[i][0] = null;
+ }
}
Event.observers = false;
},
Chris