人!
我正在为Firefox编写Web扩展程序。
我需要在扩展的弹出窗口(特别是像beforeClosed)上处理close事件来保存用户在表单中设置的数据。
我该怎么做?
答案 0 :(得分:1)
您可以使用
window.addEventListener("unload", function(){
console.log("save your data");
});
答案 1 :(得分:0)
YMMV,但接受的答案对我不起作用。 “卸载”事件从未触发。起作用的是“模糊”,将其放置在由弹出HTML文件加载的JS文件中。
@Component({
templateUrl:"my.html"
})
export class MyApp {
pressA() {
sendServer("A");
// Do other things for button A
}
pressB() {
sendServer("B");
// Do other things for button B
}
sendServer(val: string) {
// POST val to https://(mydomain)/(path)
}
}