From 275ac2c4b67f11cbd3587c8ca297e36cfca6942e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 16 Dec 2014 21:19:04 -0800 Subject: [PATCH] doc: ipc-message event --- docs/api/web-view-tag.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index d4650b683f51..b13bf2a7d61a 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -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.