зеркало из https://github.com/electron/electron.git
doc: ipc-message event
This commit is contained in:
Родитель
c0285747a2
Коммит
275ac2c4b6
|
@ -295,7 +295,7 @@ webview.addEventListener('new-window', function(e) {
|
|||
|
||||
### close
|
||||
|
||||
Fired when the guest window attempts to close itself.
|
||||
Fired when the guest page attempts to close itself.
|
||||
|
||||
The following example code navigates the `webview` to `about:blank` when the
|
||||
guest attempts to close itself.
|
||||
|
@ -306,6 +306,33 @@ webview.addEventListener('close', function() {
|
|||
});
|
||||
```
|
||||
|
||||
### ipc-message
|
||||
|
||||
* `channel` String
|
||||
* `args` Array
|
||||
|
||||
Fired when the guest page has sent an asynchronous message to browser process.
|
||||
|
||||
With `send` method and `ipc-message` event you can easily communicate between
|
||||
guest page and embedder page:
|
||||
|
||||
```javascript
|
||||
// In embedder page.
|
||||
webview.addEventListener('ipc-message', function(event) {
|
||||
console.log(event.channel);
|
||||
// Prints "pong"
|
||||
});
|
||||
webview.send('ping');
|
||||
```
|
||||
|
||||
```javascript
|
||||
// In guest page.
|
||||
var ipc = require('ipc');
|
||||
ipc.on('ping', function() {
|
||||
ipc.send('pong');
|
||||
})
|
||||
```
|
||||
|
||||
### crashed
|
||||
|
||||
Fired when the renderer process is crashed.
|
||||
|
|
Загрузка…
Ссылка в новой задаче