Skip to content

Instantly share code, notes, and snippets.

@ddramone
Created June 18, 2021 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ddramone/712a2fde2757736c9dbf6c3e7e0aa18b to your computer and use it in GitHub Desktop.
Save ddramone/712a2fde2757736c9dbf6c3e7e0aa18b to your computer and use it in GitHub Desktop.
BrowserView Background Color Bug
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Hello World!</title>
</head>
<body> <!-- You can also require other files to run in this process -->
<div id="Content"></div>
<script src="./renderer.js"></script>
</body>
</html>
const {app, BrowserWindow, BrowserView} = require('electron')
const path = require('path')
function createWindow () {
const mainWindow = new BrowserWindow({
width: 1000,
height: 800,
backgroundColor: '#55ccbb',
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.webContents.loadFile('index.html')
const offScreen = new BrowserView()
mainWindow.addBrowserView(offScreen)
offScreen.setBounds({ x: -50, y: 0, width: 400, height: 700 })
offScreen.webContents.loadURL('https://figma.com')
offScreen.setBackgroundColor('#ff00ff')
const visible = new BrowserView()
mainWindow.addBrowserView(visible)
visible.setBounds({ x: 400, y: 0, width: 400, height: 700 })
visible.webContents.loadURL('https://figma.com')
visible.setBackgroundColor('#ff00ff')
}
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
document.getElementById("Content").innerHTML = Array(1000).fill("tenderer tontent").join(' ')
})
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment