Trying to access iFrame in WebBrowser


Does anyone know if it is possible to access iframe information from the BrowserWindow object? I want to inject a new src into it but I haven’t been able to access the iframe information from the BrowserWindow.

  1. I created an instance of the browserWindow object
  2. loaded a url into the window
  3. Now I would like to access the iFrame contents of that url

Thanks for any help in advance!



I think you can only access the iframe from within the webpage that is loaded into the window, just like you would in a normal website. So you’d do something like browserWindow.loadUrl('my-app.html') in the main process and then in my-app.html you can do

<iframe id="content"/>
var iframe = document.querySelector('#content');


Thanks for your input! I actually found out that I could use .executeJavascript in the webContents object to jquery my way to the iFrame. From there I was not able to set the src because of the chromium restriction of setting a local file. Putting the file on a server did the trick though. Thanks for all your help!