Volodymyr Bezuglyy
Volodymyr Bezuglyy

Reputation: 16795

Is it possible to use Electron in web application loaded from external web server?

I started to learn Electron and have one question:
Is it possible to use Electron's code in a web application only in the case when application was loaded by Electron from local folder?

win.loadURL('file://' + __dirname + '/app/index.html');

Is it not possible to use electron in web application's java script files if application was loaded to BrowserWindow from external web server?

win.loadURL('http://localhost:9000');

Upvotes: 1

Views: 1365

Answers (2)

Philipp Hundelshausen
Philipp Hundelshausen

Reputation: 11

It is absolutely possible. BrowserWindow.loadUrl will also load an http location, localhost or otherwise.

We use this to load the application from a local webpack dev server to refresh with changes without having to restart the application let alone having to go through the entire build process.

Here you can find an example on exactly that

Upvotes: 1

Tim Rijavec
Tim Rijavec

Reputation: 1780

You can use webview to load external web content.

It is similar to iframe with the difference that it runs in a seperate process than your app and it doesn't have the same permissions as your app, to keep your app safe from the embedded content.

More about the webview can be found here

Upvotes: 0

Related Questions