Search code examples
javascriptfirefox-addondom-events

How to get notification when window closes in Firefox extension?


I am making toolbar for Mozilla Firefox. On the click of a button on my toolbar, I am opening a new window which navigates to my HTML Page created by me. On this HTML Page on the click of a button I am doing some work and closing the window.

That's all done, now I need my original or parent window's toolbar to get notified when this window is closed. I guess adding event listeners won't work as its all done in new window. Please suggest.

Any help is appreciated


Solution

  • You can use "window.onbeforeunload" event.

    Here is the reference page: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload