feat: add webContents.close() (#35509)
* feat: add webContents.close() * update docs, add test for beforeunload override * Update web-contents.md
This commit is contained in:
parent
994834d25a
commit
eebf34cc6c
5 changed files with 110 additions and 1 deletions
|
@ -934,6 +934,21 @@ Returns `string` - The title of the current web page.
|
|||
|
||||
Returns `boolean` - Whether the web page is destroyed.
|
||||
|
||||
#### `contents.close([opts])`
|
||||
|
||||
* `opts` Object (optional)
|
||||
* `waitForBeforeUnload` boolean - if true, fire the `beforeunload` event
|
||||
before closing the page. If the page prevents the unload, the WebContents
|
||||
will not be closed. The [`will-prevent-unload`](#event-will-prevent-unload)
|
||||
will be fired if the page requests prevention of unload.
|
||||
|
||||
Closes the page, as if the web content had called `window.close()`.
|
||||
|
||||
If the page is successfully closed (i.e. the unload is not prevented by the
|
||||
page, or `waitForBeforeUnload` is false or unspecified), the WebContents will
|
||||
be destroyed and no longer usable. The [`destroyed`](#event-destroyed) event
|
||||
will be emitted.
|
||||
|
||||
#### `contents.focus()`
|
||||
|
||||
Focuses the web page.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue