electron/docs/api/window-open.md

64 lines
1.7 KiB
Markdown
Raw Normal View History

2015-08-29 06:21:09 +00:00
# The `window.open` function
2015-08-29 06:21:09 +00:00
When `window.open` is called to create a new window in a web page, a new instance
of `BrowserWindow` will be created for the `url` and a proxy will be returned
to `window.open` to let the page have limited control over it.
2015-08-29 06:21:09 +00:00
The proxy has limited standard functionality implemented to be
compatible with traditional web pages. For full control of the new window
you should create a `BrowserWindow` directly.
2015-08-29 06:21:09 +00:00
### `window.open(url[, frameName][, features])`
* `url` String
2015-08-29 06:21:09 +00:00
* `frameName` String (optional)
* `features` String (optional)
Creates a new window and returns an instance of `BrowserWindowProxy` class.
2015-08-29 06:21:09 +00:00
### `window.opener.postMessage(message, targetOrigin)`
* `message` String
* `targetOrigin` String
Sends a message to the parent window with the specified origin or `*` for no
origin preference.
## Class: BrowserWindowProxy
2015-08-29 06:21:09 +00:00
The `BrowserWindowProxy` object is returned from `window.open` and provides
limited functionality with the child window.
### `BrowserWindowProxy.blur()`
Removes focus from the child window.
2015-08-29 06:21:09 +00:00
### `BrowserWindowProxy.close()`
Forcefully closes the child window without calling its unload event.
2015-08-29 06:21:09 +00:00
### `BrowserWindowProxy.closed`
Set to true after the child window gets closed.
2015-08-29 06:21:09 +00:00
### `BrowserWindowProxy.eval(code)`
* `code` String
Evaluates the code in the child window.
2015-08-29 06:21:09 +00:00
### `BrowserWindowProxy.focus()`
Focuses the child window (brings the window to front).
2015-08-29 06:21:09 +00:00
### `BrowserWindowProxy.postMessage(message, targetOrigin)`
* `message` String
* `targetOrigin` String
Sends a message to the child window with the specified origin or `*` for no
origin preference.
In addition to these methods, the child window implements `window.opener` object
2015-08-29 06:21:09 +00:00
with no properties and a single method.