[Project_owners] Sidebar onclose/unload

Daniel Muenter feedbackfox at googlemail.com
Sun Dec 17 15:33:27 PST 2006


Brian King wrote:

> [Firefox Sidebar]
>
> I can find out when my content is loading using:
>
> document.getElementById("sidebar").addEventListener("DOMContentLoaded", 
> myFunction, false);
>
> However, onclose and onunload on the content loaded in does not work. Is 
> there is a way to find out when the sidebar is closing? Preferably the 
> solution determines all cases (x button being clicked, some other 
> content taking the place of your content, Firefox closing).
>
>   
Try to use

document.getElementById('sidebar').addEventListener('unload', 
yourUnloadFunction, true);

and it should work. After initiating capture, all events of the 
specified type will be dispatched to the registered listener before 
being dispatched to any EventTargets beneath it in the DOM tree. Events 
which are bubbling upward through the tree will not trigger a listener 
designated to use capture.

Daniel


More information about the Project_owners mailing list