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?
You can use
window.addEventListener("unload", function(){
console.log("save your data");
});
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.');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.