Vingtoft
Vingtoft

Reputation: 14596

Electron: Inject raw html into BrowserWindow

Is it possbile to inject raw html code into a BrowserWindow?

mainWindow = new BrowserWindow({width: 1200, height: 800});
mainWindow.loadURL("<p>Hello, World!</p>");

The above code will crash because loadURL only accepts a file path.

Upvotes: 2

Views: 2753

Answers (1)

Shawn Rakowski
Shawn Rakowski

Reputation: 5714

You can use data urls to accomplish this:

mainWindow.loadURL("data:text/html,<p>Hello, World!</p>");

Upvotes: 7

Related Questions