-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add WebContentsView API example
- Loading branch information
1 parent
9eb162c
commit 49421c2
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// A View that displays a WebContents. | ||
// | ||
// For more info, see: | ||
// https://electronjs.org/docs/api/web-contents-view | ||
|
||
// In the main process. | ||
const { app, BaseWindow, WebContentsView } = require('electron') | ||
|
||
app.whenReady().then(() => { | ||
const win = new BaseWindow({ width: 800, height: 400 }) | ||
|
||
const view1 = new WebContentsView() | ||
win.contentView.addChildView(view1) | ||
view1.setBounds({ x: 0, y: 0, width: 400, height: 400 }) | ||
view1.webContents.loadURL('https://www.electronjs.org') | ||
|
||
const view2 = new WebContentsView() | ||
win.contentView.addChildView(view2) | ||
view2.setBounds({ x: 400, y: 0, width: 400, height: 400 }) | ||
view2.webContents.loadURL('https://www.electronjs.org/fiddle') | ||
}) |