javascript - Close Electron frameless window not working -
i'm building app using electron 1.0 , unfortunately everywhere guides , tutorials it, no 1 uses electron 1 because it's new.
i trying close frameless window through click of button made. know button works because have check make sure can simple things (i.e. change text or whatever) that's when use internal javascript trying use external javascript. when use external function never gets called...
const {remote} = require('electron'); const {browserwindow} = require('electron').remote; document.getelementbyid("close-button").addeventlistener("click", function (e) { var window = remote.getcurrentwindow(); window.close(); });
that javascript file. know linking file because can use document.write() , works.
what doing wrong here?
any appreciated thanks!
edit: added remote line.
although there reason why event handler isn't working button. question closed , answer has been accepted.
i don't know if omitted relevant import snippet posted, assuming haven't remote
undefined when call remote.getcurrentwindow()
. if add const { remote } = require('electron');
top of snippet think click handler work expected.
Comments
Post a Comment