Skip to content

Commit

Permalink
chore: Add WebContentsView API example
Browse files Browse the repository at this point in the history
  • Loading branch information
Santhoshmani1 committed Dec 18, 2024
1 parent 9eb162c commit 49421c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const SHOW_ME_TEMPLATES: Templates = {
Tray: 'Tray',
utilityProcess: 'utilityProcess',
WebContents: 'WebContents',
WebContentsView: 'WebContentsView',
WebFrame: 'WebFrame',
},
};
21 changes: 21 additions & 0 deletions static/show-me/webcontentsview/main.js
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')
})

0 comments on commit 49421c2

Please sign in to comment.