如何在 Firefox 扩展中的窗口关闭时收到通知?

发布于 2024-10-09 10:28:46 字数 197 浏览 0 评论 0原文

我正在为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光暖心i 2024-10-16 10:28:46

您可以使用“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

肩上的翅膀 2024-10-16 10:28:46

我想添加事件侦听器不会起作用,因为这一切都在新窗口中完成。

如果您将事件侦听器添加到您打开的窗口(从 window.open 调用返回的窗口),为什么不呢?

I guess adding event listeners won't work as its all done in new window.

Why not if you add the event listener to the window you've opened (the one returned from your window.open call)?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文