close window electron code example
Example 1: electron quit app from renderer
const {ipcRenderer} = require('electron');
const closeApp = document.getElementById('closeApp');
closeApp.addEventListener('click', () => {
ipcRenderer.send('close-me')
});
const {ipcMain} = require('electron')
ipcMain.on('close-me', (evt, arg) => {
app.quit()
})
Example 2: electron open new window
const button = document.getElementById('<your_button_id>');
button.addEventListener('click', () => {
createBrowserWindow();
});
function createBrowserWindow() {
const remote = require('electron').remote;
const BrowserWindow = remote.BrowserWindow;
const win = new BrowserWindow({
height: 600,
width: 800
});
win.loadURL('<url>');
}