-
-
Save Imperat/ad54907ca6e8d1167c5bde6a6bf389ac to your computer and use it in GitHub Desktop.
addBrowserView glitch
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
// Modules to control application life and create native browser window | |
const {app, BrowserWindow, BrowserView} = require('electron') | |
app.whenReady().then(async () => { | |
const win = new BrowserWindow({ | |
width: 800, | |
height: 600, | |
backgroundColor: 'black' | |
}) | |
const view1 = new BrowserView() | |
view1.setBackgroundColor('white'); | |
win.addBrowserView(view1); | |
view1.setBounds({ x: 0, y: 0, width: 800, height: 600 }) | |
await view1.webContents.loadURL('https://electronjs.org') | |
const view2 = new BrowserView(); | |
view2.setBackgroundColor('white'); | |
win.addBrowserView(view2); | |
view2.setBounds({ x: 0, y: 0, width: 800, height: 600 }) | |
await view2.webContents.loadURL('https://www.electronjs.org/apps'); | |
setInterval(() => { | |
win.removeBrowserView(view2); | |
setTimeout(() => { | |
win.addBrowserView(view2); | |
}, 1000); | |
}, 3000); | |
}) |
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
{ | |
"name": "upbeat-structure-plan-e743d", | |
"productName": "upbeat-structure-plan-e743d", | |
"description": "My Electron application description", | |
"keywords": [], | |
"main": "./main.js", | |
"version": "1.0.0", | |
"author": "leliakin", | |
"scripts": { | |
"start": "electron ." | |
}, | |
"dependencies": {}, | |
"devDependencies": { | |
"electron": "20.1.4" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment