Windows 10 will reach EOS (end of support) on October 14, 2025. For more information, see this article.

Etsi tuesta

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Lue lisää

What API events are triggered when closing a FirefoxOS app

  • 2 vastausta
  • 1 henkilöllä on sama ongelma
  • 11 näyttöä
  • Viimeisin kirjoittaja harry

more options

I need to check for unsaved data when an app is closed (using the close button at the bottom of the screen and then pressing the X that is top left when the app appears reduced size).

I've managed to add an event listener for the low battery condition and this works as expected. But looking at https://developer.mozilla.org/en-US/docs/Web/Events I can't decide which event is correct for closing an app.

The obvious one -- close -- seems to be something to do with web sockets.

mozbrowserclose seems to be triggered when closing by the app's software.

XUL close "the user presses the close button" seems like the appropriate one, but when trying

window.addEventListener("close", function( event )

   {
        window.alert("closing");
   }, false);

the app closes without triggering the alert.

DOMWindowClose seems to be specific for close by window.close in software

mozbrowserclose seems to be specific to iframes

So ... does anybody know the correct event to trap ?

Phone is ZTE Open C with FFOS 1.3.

I need to check for unsaved data when an app is closed (using the close button at the bottom of the screen and then pressing the X that is top left when the app appears reduced size). I've managed to add an event listener for the low battery condition and this works as expected. But looking at https://developer.mozilla.org/en-US/docs/Web/Events I can't decide which event is correct for closing an app. The obvious one -- close -- seems to be something to do with web sockets. mozbrowserclose seems to be triggered when closing by the app's software. XUL close "the user presses the close button" seems like the appropriate one, but when trying window.addEventListener("close", function( event ) { window.alert("closing"); }, false); the app closes without triggering the alert. DOMWindowClose seems to be specific for close by window.close in software mozbrowserclose seems to be specific to iframes So ... does anybody know the correct event to trap ? Phone is ZTE Open C with FFOS 1.3.

Kaikki vastaukset (2)

more options

Hi harry.green,

These support forums are geared to answering how-to and basic questions about Mozilla's products. Developer-related questions don't usually get much traffic here in SUMO.

You are likely to find help from experienced developers and additional resources in the following channels:

I hope you find this information helpful. Please let us know if you have any questions about the usage of your Firefox OS device. =)

Thanks,

- Ralph

more options

I tried posting in stack overflow, but had no replies there.

Hunting around, I suspect this is https://bugzilla.mozilla.org/show_bug.cgi?id=996754 "User-terminated apps do not receive 'beforeunload' event" but there is currently nobody even working on it.

So, we have to put up programs having no way to save their data when they get unloaded? Seems like a very bad design feature to me, one which really ought to be looked at with a much higher priority than is likely to happen from the bug report which has already been ignored for six months.