Dmitro Liakhov
Dmitro Liakhov

Reputation: 96

Firefox Extension: close event on popup

guys!

I am writing web extension for Firefox.

I need to handle close event on popup window of extension (specifically, like beforeClosed) to save data, which user set in form.

How can I do this?

Upvotes: 1

Views: 966

Answers (2)

salient.salamander
salient.salamander

Reputation: 149

YMMV, but the accepted answer did not work for me. The 'unload' event never fired. What did work was 'blur', placed in a JS file that is loaded by the popup HTML file.

window.addEventListener('blur', function (event) {
  console.log('Window closing.');
});

Upvotes: 1

Smile4ever
Smile4ever

Reputation: 3704

You can use

window.addEventListener("unload", function(){
  console.log("save your data");
});

Source: Firefox Extension - onPopupClose event?

Upvotes: 3

Related Questions