Skip to content
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

Access BrowserView DOM objects in Electron.NET #476

Open
PeterPolaschek opened this issue Aug 24, 2020 · 1 comment
Open

Access BrowserView DOM objects in Electron.NET #476

PeterPolaschek opened this issue Aug 24, 2020 · 1 comment
Labels

Comments

@PeterPolaschek
Copy link

@PeterPolaschek PeterPolaschek commented Aug 24, 2020

Hi guys,
I have an Electron App with a BrowserView in the main BrowserWindow. In the BrowserView, I load an external URL:

// main.js:
BrowserWindow mainWindow = new BrowserWindow(...);
BrowserView view = new BrowserView(...);
mainWindow.setBrowserView(view);
view.webContents.loadURL(...);

To access the BrowserView's content, I send it to the renderer.js:

// main.js:
ipcMain.on("event", function (event, arg) {
    view.webContents.send("channel");
});

In renderer.js, I can access the BrowserView's content:

// renderer.js
ipcRenderer.on("channel", () => {
    var html = document.getElementById("elementId").innerHTML;
});

I want to do the same within an Electron.NET application but there doesn't seem to be the following function:
view.webContents.send("channel");

Will this functionality or an equivalent be available in Electron.NET anytime soon?

@freosc
Copy link
Contributor

@freosc freosc commented Aug 26, 2020

If you take a look at the IPC view and controller in the ElectronNET.WebApp example project, you'll see how it's done.

var mainWindow = Electron.WindowManager.BrowserWindows.First();
Electron.IpcMain.Send(mainWindow, "channel", "argument");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.