electron show 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: electron specify minimum size

const screenElectron = electron.screen;
const display = screenElectron.getPrimaryDisplay();
const dimensions = display.workAreaSize;
mainWindow = new BrowserWindow({
    width: parseInt(dimensions.width * 0.8),
    height: parseInt(dimensions.height * 0.8),
    minWidth: parseInt(dimensions.width * 0.8),
    minHeight: parseInt(dimensions.height * 0.8),
    maxWidth: dimensions.width,
    maxHeight: dimensions.height,
    icon: `${__dirname}/assets/icon.ico`
  });

Tags:

Html Example