doc: ipc-message event

This commit is contained in:
Cheng Zhao 2014-12-16 21:19:04 -08:00
parent c0285747a2
commit 275ac2c4b6

View file

@ -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.