Reputation: 96
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
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
Reputation: 3704
You can use
window.addEventListener("unload", function(){
console.log("save your data");
});
Source: Firefox Extension - onPopupClose event?
Upvotes: 3