0

I was just developing an electron app and was quickly making a close button for the app. Here is some of the code:
HTML for button

<button id="close-btn">close app</button>

Javascript (frontend)

const electron = require('electron').remote

const closeBtn = document.getElementById('close-btn')

closeBtn.addEventListener('click', function (e) {
  var window = electron.getCurrentWindow();
  window.close();
})

And for some reason when I tested the button out, it didn't work! And my webPrefrences had nodeIntegration set to true and contextIsolation set to false. I checked if I linked the JS file correctly with an alert on a click event and it worked just fine. \

Anyone know what's going on and how to fix it?

Pro Poop
  • 357
  • 5
  • 14
  • 1
    are you using the devtools? are you getting any errors there? did you log the window object to see if it is as expected and has the close method? – João Vítor Costa Apr 24 '21 at 17:42
  • probably dupe of [this](https://stackoverflow.com/questions/37884130/electron-remote-is-undefined). Did you enable `enableRemoteModule`? – pushkin Apr 24 '21 at 17:46

0 Answers0