Opening windows from the renderer
- clicking on links or submitting forms adorned with
target=_blank
For same-origin content, the new window is created within the same process,
enabling the parent to access the child window directly. This can be very
useful for app sub-windows that act as preference panels, or similar, as the
parent can render to the sub-window directly, as if it were a div
in the
parent. This is the same behavior as in the browser.
Electron pairs this native Chrome Window
with a BrowserWindow under the hood.
You can take advantage of all the customization available when creating a
BrowserWindow in the main process by using webContents.setWindowOpenHandler()
for renderer-created windows.
url
stringframeName
string (optional)- string (optional)
Returns Window
| null
features
is a comma-separated key-value list, following the standard format of
the browser. Electron will parse BrowserWindowConstructorOptions
out of this
list where possible, for convenience. For full control and better ergonomics,
consider using webContents.setWindowOpenHandler
to customize the
BrowserWindow creation.
For example:
Notes:
- Context isolation will always be enabled in the opened
window
if it is enabled on the parent window. - JavaScript will always be disabled in the opened if it is disabled on the parent window.
- Non-standard features (that are not handled by Chromium or Electron) given in
features
will be passed to any registeredwebContents
‘sdid-create-window
event handler in theoptions
argument. - When opening
about:blank
, the child window’sWebPreferences
will be copied from the parent window, and there is no way to override it because Chromium skips browser side navigation in this case.