Skip to content

Instantly share code, notes, and snippets.

@codebytere
Created November 30, 2020 04:54
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 codebytere/7278c8c62ec976110afb47ef2d861a7a to your computer and use it in GitHub Desktop.
Save codebytere/7278c8c62ec976110afb47ef2d861a7a to your computer and use it in GitHub Desktop.
browserview-exclusive-windows
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<link rel="stylesheet" type="text/css" href="./styles.css">
</head>
<body>
<h1>Hello World!</h1>
<h1 style="-webkit-app-region : drag ; border : 1px solid red; width: 300; height: 200; display: inline; -webkit-user-select: none;">DRAGGABLE AREA</h1>
<script>
// You can also require other files to run in this process
require('./renderer.js')
</script>
</body>
</html>
// Modules to control application life and create native browser window
const { app, BrowserWindow, BrowserView } = require('electron')
app.whenReady().then(() => {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 500,
frame: false,
titleBarStyle: "hiddenInset"
})
mainWindow.loadFile("index.html");
const view = new BrowserView();
mainWindow.addBrowserView(view);
view.setBounds({
x: 400,
y: 0,
width: 400,
height: 300,
});
view.webContents.loadFile("index.html");
view.setAutoResize({
width: true,
height: true,
});
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment