0

It seems like chrome.tabs.onRemoved.addListener doesn't fire when Chrome shuts down. Is there a way to track a Chrome shutdown event?

Niko
  • 369
  • 1
  • 3
  • 14
  • Possible duplicate of [Trying to detect browser close event](https://stackoverflow.com/questions/20853142/trying-to-detect-browser-close-event) [Chrome extension action on shutdown](https://stackoverflow.com/questions/18501062/chrome-extension-action-on-shutdown) – Crocsx Sep 03 '19 at 05:44

2 Answers2

1

There is no guarantee that your extension will be able to handle an event, see Chrome extension action on shutdown

0

Two of the most popular events of HTML DOM that are used to detect browser's close event are onunload and onbeforeunload. Using onunload is pretty straight forward, just subscribe the JavaScript event. onunload works okay on Internet Explorer, but doesn't work fine in Mozilla Firefox. On the other hand, onbeforeunload works okay on IE,Firefox and chrome, so using onbeforeunload is safe.

<script language="JavaScript">
window.onbeforeunload = WindowCloseHanlder;
function WindowCloseHanlder()
{   
window.alert('My Window is closing');
}
</script>
Ajay Kumar Oad
  • 560
  • 5
  • 15