docs: added windows -> create frameless window example (#20591)
* docs: added windows -> create frameless window example from electron-api-docs * fixed style in accord with StandardJS * removed class tag from button
This commit is contained in:
parent
a15e0e0657
commit
821bcdef75
3 changed files with 63 additions and 0 deletions
|
@ -0,0 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<div>
|
||||
<h1>Create a frameless window</h1>
|
||||
<i>Supports: Win, macOS, Linux <span>|</span> Process: Main</i>
|
||||
<div>
|
||||
<p>A frameless window is a window that has no <i>"chrome"</i>,
|
||||
such as toolbars, title bars, status bars, borders, etc. You can make
|
||||
a browser window frameless by setting
|
||||
<code>frame</code> to <code>false</code> when creating the window.</p>
|
||||
<div>
|
||||
<button id="frameless-window">View Demo</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
require('./renderer.js')
|
||||
</script>
|
||||
</html>
|
|
@ -0,0 +1,25 @@
|
|||
const { app, BrowserWindow } = require('electron')
|
||||
|
||||
let mainWindow = null
|
||||
|
||||
function createWindow () {
|
||||
const windowOptions = {
|
||||
width: 600,
|
||||
height: 400,
|
||||
title: 'Create a frameless window',
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(windowOptions)
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null
|
||||
})
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
createWindow()
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
const { BrowserWindow } = require('electron').remote
|
||||
|
||||
const newWindowBtn = document.getElementById('frameless-window')
|
||||
|
||||
newWindowBtn.addEventListener('click', (event) => {
|
||||
let win = new BrowserWindow({ frame: false })
|
||||
|
||||
win.on('close', () => { win = null })
|
||||
|
||||
win.loadURL('data:text/html,<h2>Hello World!</h2><a id="close" href="javascript:window.close()">Close this Window</a>')
|
||||
win.show()
|
||||
})
|
Loading…
Reference in a new issue