electron render process onload 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 new window
const electron = require('electron')
const BrowserWindow = electron.remote.BrowserWindow
$( "#target" ).click(function() {
let win = new BrowserWindow({ show: false })
win.on('close', function () { win = null })
win.loadURL("github.com")
win.once('ready-to-show', () => {
win.show()
})
});