2016-05-17 23:02:54 +00:00
|
|
|
# `window.open` Function
|
2015-03-04 16:47:04 +00:00
|
|
|
|
2016-04-22 18:42:54 +00:00
|
|
|
> Open a new window and load a URL.
|
2016-04-21 22:35:29 +00:00
|
|
|
|
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
|
2015-07-14 15:37:52 +00:00
|
|
|
to `window.open` to let the page have limited control over it.
|
2015-03-04 16:47:04 +00:00
|
|
|
|
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
|
2015-03-04 16:47:04 +00:00
|
|
|
you should create a `BrowserWindow` directly.
|
|
|
|
|
2016-07-22 22:00:10 +00:00
|
|
|
The newly created `BrowserWindow` will inherit the parent window's options by
|
|
|
|
default. To override inherited options you can set them in the `features`
|
2015-09-22 14:46:44 +00:00
|
|
|
string.
|
|
|
|
|
2015-08-29 06:21:09 +00:00
|
|
|
### `window.open(url[, frameName][, features])`
|
2015-03-04 16:47:04 +00:00
|
|
|
|
|
|
|
* `url` String
|
2015-08-29 06:21:09 +00:00
|
|
|
* `frameName` String (optional)
|
|
|
|
* `features` String (optional)
|
2015-03-04 16:47:04 +00:00
|
|
|
|
2016-09-24 23:59:30 +00:00
|
|
|
Returns `BrowserWindowProxy` - Creates a new window and returns an instance of `BrowserWindowProxy` class.
|
2015-03-04 16:47:04 +00:00
|
|
|
|
2015-09-22 14:46:44 +00:00
|
|
|
The `features` string follows the format of standard browser, but each feature
|
|
|
|
has to be a field of `BrowserWindow`'s options.
|
|
|
|
|
2016-03-30 17:55:16 +00:00
|
|
|
**Note:** Node integration will always be disabled in the opened `window` if it
|
|
|
|
is disabled on the parent window.
|
|
|
|
|
2015-08-29 06:21:09 +00:00
|
|
|
### `window.opener.postMessage(message, targetOrigin)`
|
2015-03-04 16:47:04 +00:00
|
|
|
|
|
|
|
* `message` String
|
|
|
|
* `targetOrigin` String
|
|
|
|
|
|
|
|
Sends a message to the parent window with the specified origin or `*` for no
|
|
|
|
origin preference.
|
|
|
|
|
|
|
|
## Class: BrowserWindowProxy
|
|
|
|
|
2016-08-25 22:20:05 +00:00
|
|
|
> Manipulate the child browser window
|
|
|
|
|
2015-08-29 06:21:09 +00:00
|
|
|
The `BrowserWindowProxy` object is returned from `window.open` and provides
|
|
|
|
limited functionality with the child window.
|
|
|
|
|
2016-07-13 04:57:07 +00:00
|
|
|
### Instance Methods
|
|
|
|
|
|
|
|
The `BrowserWindowProxy` object has the following instance methods:
|
|
|
|
|
2016-07-22 22:00:10 +00:00
|
|
|
#### `win.blur()`
|
2015-03-04 16:47:04 +00:00
|
|
|
|
|
|
|
Removes focus from the child window.
|
|
|
|
|
2016-07-22 22:00:10 +00:00
|
|
|
#### `win.close()`
|
2015-03-04 16:47:04 +00:00
|
|
|
|
|
|
|
Forcefully closes the child window without calling its unload event.
|
|
|
|
|
2016-07-22 22:00:10 +00:00
|
|
|
#### `win.eval(code)`
|
2015-03-04 16:47:04 +00:00
|
|
|
|
|
|
|
* `code` String
|
|
|
|
|
|
|
|
Evaluates the code in the child window.
|
|
|
|
|
2016-07-22 22:00:10 +00:00
|
|
|
#### `win.focus()`
|
2015-03-04 16:47:04 +00:00
|
|
|
|
|
|
|
Focuses the child window (brings the window to front).
|
|
|
|
|
2016-07-22 22:00:10 +00:00
|
|
|
#### `win.print()`
|
2016-05-26 16:35:26 +00:00
|
|
|
|
|
|
|
Invokes the print dialog on the child window.
|
|
|
|
|
2016-07-22 22:00:10 +00:00
|
|
|
#### `win.postMessage(message, targetOrigin)`
|
2015-03-04 16:47:04 +00:00
|
|
|
|
|
|
|
* `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.
|
2016-08-25 17:52:19 +00:00
|
|
|
|
|
|
|
### Instance Properties
|
|
|
|
|
|
|
|
The `BrowserWindowProxy` object has the following instance properties:
|
|
|
|
|
|
|
|
#### `win.closed`
|
|
|
|
|
2016-09-24 23:59:30 +00:00
|
|
|
A Boolean that is set to true after the child window gets closed.
|