Is there an event for when a Chrome Extension popup is closed?

前端 未结 4 1804
说谎
说谎 2020-11-29 05:28

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.

4条回答
  •  北海茫月
    2020-11-29 05:41

    There is currently no way to figure out when the browser action popup was closed as window.unonload is triggered immediately when the popup finished loading, not when it's closed. There is a bug crbug.com/31262 for this.

    Three work arounds available are well described here. They include the port.onDisconnect trick and periodically polling chrome.extension.getViews() from either the popup or a background page.

提交回复
热议问题