I've created a browser window that uses a check box to open and close itself however, only the checkbox in its true
state is being detected and not in its false
state.
Here is my code in the renderer.js:
const {width, height} = screen.getPrimaryDisplay().workAreaSize;
let close = document.querySelector('input[name=open_close]');
close.addEventListener('change', function(event){
if (this.checked = true) {
console.log("renderer");
ipcRenderer.send('expClose',width, height);
}
if(this.checked = false) {
ipcRenderer.send('expOpen',width - 500, height - 450);
}
});
And here is my my main.js:
ipcMain.on('expClose', function(e,width, height) {
console.log('closed');
mainWindow.setPosition(width - 75, height - 450);
});
ipcMain.on('expOpen', function(e,width, height) {
console.log("opened")
mainWindow.setPosition(width, height);
});
Also my HTML if needed:
<input type="checkbox" name="setbtn" checked="false" id="settings" class="btnset">
I assumed that the false state isn't being detected because opened isn't being logged. Any help will be greatly appreciated.
Your using =
(assignment) instead of ===
(comparison)
Change if (this.checked = true) {
to if (this.checked === true) {
and if(this.checked = false) {
to if(this.checked === false) {
Thanks ill try this code!