Script Electron


Hi, i have installed electron in global mode and i want to use it to run little script with GUI contained in one file. (I associated the *.js files in windows 10 to be opened with electron.)
I wrote this file:

const {
} = require('electron')

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow

function createWindow() {

  var html = `<html>
      body {
        background-color: whitesmoke;
      Input1: <input id="ia"><br><br>
      Input2: <input id="ib"><br><br>
      Input3: <input id="ic" type="number"><br><br>
      <button onclick="f()">Ok</button><br><br>
      <div id="output"></div>
      function f() {
        var i1 = document.querySelector("#ia").value
  var win = new BrowserWindow({
    width: 450,
    height: 350,
    title: 'scriptElectron',
    show: false
  win.loadURL(`javascript:document.body.innerHTML = '${html}'`)
  // win.loadURL('file://')
  // win.webContents.executeJavaScript(`document.body.innerHTML = '${html}'`, function (result) {
  //   console.log(result)
  // })

app.on('ready', createWindow)

app.on('window-all-closed', function () {
  // On OS X it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
  if (process.platform !== 'darwin') {

app.on('activate', function () {
  // On OS X it's common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (mainWindow === null) {

but javascript doesn’t run. If in the definition of “f” i write only “alert(”")" i see the alert dialog but with var i1 = document.querySelector("#ia").value it doesn’t work.
How can i solve this problem?


Fixed i must insert “;” document.querySelector("#ia").value;