]> khamidou — GitHub mirrors - electron.git/commitdiff
doc: ipc-message event
authorCheng Zhao <zcbenz@gmail.com>
Wed, 17 Dec 2014 05:19:04 +0000 (21:19 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 17 Dec 2014 05:19:04 +0000 (21:19 -0800)
docs/api/web-view-tag.md

index d4650b683f51cb6bc89b30d0539ac3add69a5c1f..b13bf2a7d61a44e7a2334dc03bb7752cf3290c7b 100644 (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.