When a chrome app window is closed, is it possible to detect the event? and do an action before the window is closed?
Open Event Viewer by clicking the Start button , clicking Control Panel, clicking System and Security, clicking Administrative Tools, and then double-clicking Event Viewer.
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.
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.
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.
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)
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.
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.
chrome.app.window.current().onClosed allows you to register an event listener for when a window is closed.
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(){...})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With