-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
webview and @electron/remote #96
Comments
This used to work in version 1.x with the |
same error |
const mainWindow = new BrowserWindow(opts)
remoteMain.enable(mainWindow.webContents);
mainWindow.webContents.on('will-attach-webview', () => {
const all = webContents.getAllWebContents();
all.forEach((item) => {
remoteMain.enable(item);
});
}); |
@nevermore-kl I tried your code but didn't worked. Below follows the electron and @electron/remote versions that I'm using. Do you have any suggestion to enable @electron/remote inside an electron-tab webview?
|
Anyone can help or give some advice? |
@nevermore-kl, after adding your code I also add to set the webPreferences inside webviewAttributes when adding a new TAB like this:
Without setting the |
Changing const mainWindow = new BrowserWindow(opts)
remoteMain.enable(mainWindow.webContents);
mainWindow.webContents.on('did-attach-webview', () => {
const all = webContents.getAllWebContents();
all.forEach((item) => {
remoteMain.enable(item);
});
}); |
sorry I forgot I set it before |
replace |
this is the best way |
Electron version: 15.3.1
@electron/remote version: 2.0.1
When adding a
<webview />
that has a preload script that imports@electron/remote
I getError: @electron/remote is disabled for this WebContents.
.electronRemoteMain.enable(window.webContents);
is ran on theBrowserWindow
that renders the webview and the wrapping React component is able to use@electron/remote
, but the webview hasn't been enabled.Is there a way of enabling the remote module for a webview?
The text was updated successfully, but these errors were encountered: