Chrome 扩展弹出窗口关闭时是否有事件? [英] Is there an event for when a Chrome Extension popup is closed?

查看:13
本文介绍了Chrome 扩展弹出窗口关闭时是否有事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过 window.unload、window.beforeunload 等.我正在寻找一种方法来在弹出窗口关闭后通知我的后台页面.

I've already tried window.unload, window.beforeunload, etc. I'm looking for a way to notify my background page once the popup is closed.

推荐答案

你可以试试这个.使用 chrome.runtime.connect(或 chrome.extension.connect 在 Chrome 26 之前)和 port.onDisconnect 将在弹出窗口关闭时在您的后台页面中触发.

You can try this. Connect to your background page with chrome.runtime.connect (or chrome.extension.connect before Chrome 26) and port.onDisconnect will be fired in your background page when the popup is closed.

这篇关于Chrome 扩展弹出窗口关闭时是否有事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆