docs: remove outdated ipc example (#37523)
This commit is contained in:
parent
77bd80dfb2
commit
f33bf2a271
1 changed files with 7 additions and 33 deletions
|
@ -786,7 +786,7 @@ cancel the request.
|
||||||
|
|
||||||
If no event listener is added for this event, all bluetooth requests will be cancelled.
|
If no event listener is added for this event, all bluetooth requests will be cancelled.
|
||||||
|
|
||||||
```javascript
|
```javascript title='main.js'
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
let win = null
|
let win = null
|
||||||
|
@ -1631,7 +1631,7 @@ ipcMain.on('open-devtools', (event, targetContentsId, devtoolsContentsId) => {
|
||||||
|
|
||||||
An example of showing devtools in a `BrowserWindow`:
|
An example of showing devtools in a `BrowserWindow`:
|
||||||
|
|
||||||
```js
|
```js title='main.js'
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
let win = null
|
let win = null
|
||||||
|
@ -1714,40 +1714,14 @@ Algorithm][SCA], just like [`postMessage`][], so prototype chains will not be
|
||||||
included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will
|
included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will
|
||||||
throw an exception.
|
throw an exception.
|
||||||
|
|
||||||
> **NOTE**: Sending non-standard JavaScript types such as DOM objects or
|
:::warning
|
||||||
> special Electron objects will throw an exception.
|
|
||||||
|
|
||||||
The renderer process can handle the message by listening to `channel` with the
|
Sending non-standard JavaScript types such as DOM objects or
|
||||||
[`ipcRenderer`](ipc-renderer.md) module.
|
special Electron objects will throw an exception.
|
||||||
|
|
||||||
An example of sending messages from the main process to the renderer process:
|
:::
|
||||||
|
|
||||||
```javascript
|
For additional reading, refer to [Electron's IPC guide](../tutorial/ipc.md).
|
||||||
// In the main process.
|
|
||||||
const { app, BrowserWindow } = require('electron')
|
|
||||||
let win = null
|
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
|
||||||
win = new BrowserWindow({ width: 800, height: 600 })
|
|
||||||
win.loadURL(`file://${__dirname}/index.html`)
|
|
||||||
win.webContents.on('did-finish-load', () => {
|
|
||||||
win.webContents.send('ping', 'whoooooooh!')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!-- index.html -->
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
<script>
|
|
||||||
require('electron').ipcRenderer.on('ping', (event, message) => {
|
|
||||||
console.log(message) // Prints 'whoooooooh!'
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `contents.sendToFrame(frameId, channel, ...args)`
|
#### `contents.sendToFrame(frameId, channel, ...args)`
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue