Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close event for chrome.app.window

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

like image 532
Stefania Avatar asked Mar 27 '13 15:03

Stefania


People also ask

Does Chrome have an event viewer?

Open Event Viewer by clicking the Start button , clicking Control Panel, clicking System and Security, clicking Administrative Tools, and then double-clicking Event Viewer.

What is window chrome?

Remarks. The WindowChrome class enables you to extend Windows Presentation Foundation (WPF) content into the non-client area of a window that is typically reserved for the operating system's window manager.

How do I make Chrome window always on top?

To set a webpage on top you just need to open the webpage in Google Chrome, then right-click and then select 'Always On Top'. The webpage will be opened in a new customized window that would always stay on top.

What is the closing event of an app window?

App Window. Closing Event Microsoft. UI. Windowing Occurs when a window is being closed through a system affordance. TypedEventHandler < AppWindow, AppWindowClosingEventArgs > This event does not occur when the AppWindow.Destroy method is called.

How to detect browser or tab close event?

Way to detect browser or tab close event Perform database operation before close the browser (without alert) Show alert before close/reload the tab or browser 1. Perform database operation before close the browser (without alert)

How to handle beforeunloadevent to detect browser Close in JavaScript?

1. Perform database operation before close the browser (without alert) Here, we will use the addEventListener()method to handle the beforeunloadevent to detect browser close. Use the following code to perform the DB operation or data manipulation.

How to show alert before close/reload the tab or browser?

Show alert before close/reload the tab or browser 1. Perform database operation before close the browser (without alert) Here, we will use the addEventListener()method to handle the beforeunloadevent to detect browser close. Use the following code to perform the DB operation or data manipulation.


2 Answers

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

like image 191
Vincent Scheib Avatar answered Jan 01 '23 21:01

Vincent Scheib


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(){...})
like image 29
posit labs Avatar answered Jan 01 '23 19:01

posit labs