Close event for chrome.app.window

后端 未结 2 1041
失恋的感觉
失恋的感觉 2020-12-09 06:25

When a chrome app window is closed, is it possible to detect the event? and do an action before the window is closed?

相关标签:
2条回答
  • 2020-12-09 06:37

    Vincent's answer will work in some cases, but the documentation warns that some chrome api functionality will be lost by the time the onClosed event is fired.

    Note, this should be listened to from a window other than the window being closed, for example from the background page

    To listen for this event from the background page, do something like this:

    chrome.app.window.get(windowIDUsedToCreateChildWindow).onClosed.addListener(function(){...})
    
    0 讨论(0)
  • 2020-12-09 07:02

    chrome.app.window.current().onClosed allows you to register an event listener for when a window is closed.

    0 讨论(0)
提交回复
热议问题