Skip to content

Commit

Permalink
docs: fix webContents 'new-window' event handler sample (#18097)
Browse files Browse the repository at this point in the history
  • Loading branch information
trop[bot] authored and codebytere committed May 1, 2019
1 parent 1154f3c commit 2483dcc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions docs/api/web-contents.md
Expand Up @@ -138,11 +138,16 @@ new [`BrowserWindow`](browser-window.md). If you call `event.preventDefault()` a
instance, failing to do so may result in unexpected behavior. For example:

```javascript
myBrowserWindow.webContents.on('new-window', (event, url) => {
myBrowserWindow.webContents.on('new-window', (event, url, frameName, disposition, options) => {
event.preventDefault()
const win = new BrowserWindow({ show: false })
const win = new BrowserWindow({
webContents: options.webContents, // use existing webContents if provided
show: false
})
win.once('ready-to-show', () => win.show())
win.loadURL(url)
if (!options.webContents) {
win.loadURL(url) // existing webContents will be navigated automatically
}
event.newGuest = win
})
```
Expand Down

0 comments on commit 2483dcc

Please sign in to comment.