From c3c67f78c1c57cd15c455d7210acc4f5c4f76f08 Mon Sep 17 00:00:00 2001 From: Ryohei Ikegami Date: Sun, 19 Mar 2017 20:30:07 +0900 Subject: [PATCH] Improve docs on window.open --- docs/api/window-open.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/api/window-open.md b/docs/api/window-open.md index 19c746737a9e..b0cd0e25011b 100644 --- a/docs/api/window-open.md +++ b/docs/api/window-open.md @@ -50,8 +50,16 @@ Native `window.open()` allows synchronous access to opened windows so it is conv The creation of the `BrowserWindow` is customizable in `WebContents`'s `new-window` event. ```javascript +// main process +const mainWindow = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + nativeWindowOpen: true + } +}) mainWindow.webContents.on('new-window', (event, url, frameName, disposition, options, additionalFeatures) => { - if (url.endsWith('modal.html')) { + if (frameName === 'modal') { // open window as modal event.preventDefault() Object.assign(options, { @@ -65,3 +73,9 @@ mainWindow.webContents.on('new-window', (event, url, frameName, disposition, opt } }) ``` + +```javascript +// renderer process (mainWindow) +let modal = window.open('', 'modal') +modal.document.write('

Hello

') +```