electron get browser window code example

Example 1: 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()
	})
});

Example 2: create window electron

const createWindow = () => {
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 400,
  });
  mainWindow.loadFile(path.join(__dirname, 'index.html'));
};

Tags:

Html Example