ipc
An IpcMain
instance scoped to the frame.
IPC messages sent with ipcRenderer.send
, ipcRenderer.sendSync
or ipcRenderer.postMessage
will be delivered in the following order:
contents.on('ipc-message')
contents.mainFrame.on(channel)
contents.ipc.on(channel)
ipcMain.on(channel)
Handlers registered with invoke
will be checked in the following order. The first one that is defined will be called, the rest will be ignored.
contents.mainFrame.handle(channel)
contents.handle(channel)
ipcMain.handle(channel)
In most cases, only the main frame of a WebContents can send or receive IPC messages. However, if the nodeIntegrationInSubFrames
option is enabled, it is possible for child frames to send and receive IPC messages also. The WebContents.ipc
interface may be more convenient when nodeIntegrationInSubFrames
is not enabled.