如何在 Firefox 扩展中的窗口关闭时收到通知?
我正在为 Mozilla Firefox 制作工具栏。单击工具栏上的按钮后,我将打开一个新窗口,该窗口导航到我创建的 HTML 页面。在这个 HTML 页面上,单击按钮,我正在做一些工作并关闭窗口。
一切都完成了,现在我需要原始窗口或父窗口的工具栏在该窗口关闭时收到通知。我想添加事件监听器不会像在新窗口中完成的那样工作。请建议。
任何帮助表示赞赏
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用“window.onbeforeunload”事件。
以下是参考页面:https://developer.mozilla。 org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
You can use "window.onbeforeunload" event.
Here is the reference page: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
如果您将事件侦听器添加到您打开的窗口(从 window.open 调用返回的窗口),为什么不呢?
Why not if you add the event listener to the window you've opened (the one returned from your window.open call)?