Guys i need to open some web application into my electron app, i used <webview>
tag but [official docs][1] of electron offers to use BrowserView
.
so i used BrowserView
, BUT i got DevTools was disconnected from the page error!
simply i need DevTools for my BrowserView
not my entire app. what should i do?
myCode: just main.js
const {app, BrowserView, BrowserWindow} = require('electron'); let win; let view; app.on('ready', () => { win = new BrowserWindow({width: 800, height: 600}); win.on('closed', () => { win = null }); view = new BrowserView({ webPreferences: { nodeIntegration: false } }); win.setBrowserView(view); view.setBounds({x: 0, y: 0, width: 800, height: 600}); view.webContents.loadURL('https://example.com'); win.openDevTools(); });
Advertisement
Answer
openDevTools
is basically a function of webContents
(when used on BrowserWindow
it’s only redirected)
So you can open devtools of main window with
win.webContents.openDevTools()
And for the BrowserView
with
view.webContents.openDevTools()