Adjust to the new behaviors of beforeunload handler

This commit is contained in:
Cheng Zhao 2016-05-23 13:28:16 +09:00
parent 06800940ec
commit fa0ce7ad5f
5 changed files with 8 additions and 29 deletions

View file

@ -217,17 +217,17 @@ will cancel the close.
Usually you would want to use the `beforeunload` handler to decide whether the
window should be closed, which will also be called when the window is
reloaded. In Electron, returning an empty string or `false` would cancel the
reloaded. In Electron, returning any value other than `undefined` would cancel the
close. For example:
```javascript
window.onbeforeunload = (e) => {
console.log('I do not want to be closed');
// Unlike usual browsers, in which a string should be returned and the user is
// prompted to confirm the page unload, Electron gives developers more options.
// Returning empty string or false would prevent the unloading now.
// You can also use the dialog API to let the user confirm closing the application.
// Unlike usual browsers that a message box will be prompted to users, returning
// a non-void value will silently cancel the close.
// It is recommended to use the dialog API to let the user confirm closing the
// application.
e.returnValue = false;
};
```