Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

395
Views
Electron Uncaught Exception: TypeError: Cannot read properties of null (reading 'on')

The error appears only if i open a new window when the inspector is opened once. It does'nt appear for mainWindow.

enter image description here

// Detect maximize-unmaximize to change the maximize button's icon
app.on('browser-window-focus', (event, win) => {
  console.log('Focus: ' + win.webContents.id);
  BrowserWindow.fromId(win.webContents.id).on('ready-to-show', () => {
    BrowserWindow.fromId(win.webContents.id).on('maximize', () => {
      console.log("maximize detected", win.webContents.id);
      BrowserWindow.fromId(win.webContents.id).send('window-events', 'maximize');
    })
    BrowserWindow.fromId(win.webContents.id).on('unmaximize', () => {
      console.log("unmaximize detected", win.webContents.id);
      BrowserWindow.fromId(win.webContents.id).send('window-events', 'unmaximize');
    })
  })
})
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

This happens because you are using the same webview instance of your browser windows. You can fix this by creating a separate webview in each window and then use that instead. For example, try changing it as follows:

var myBrowser = require('electron').remote.getGlobal('Browser'); var myBrowser2 = require('electron').remote.getGlobal('Browser2');

myBrowser.webContents.on('dom-ready', function(){ myBrowser2.webContents.send('window-events', 'maximize') }); myBrowser2.webContents.on('dom-ready', function(){ myBrowser.webContents.send('window-events', 'unmaximize') });

You will need to make sure that both windows have their own unique id so that they do not conflict with one another. Also note that I am assuming you want to send these events from within the renderer process itself. If you would like to receive them on the main process side, you should be able to listen for "window-events" on the remote object returned by getGlobal.

about 4 years ago · Juan Pablo Isaza Report

0

I solved the problem with using .getFocusedWindow() instead of .fromId. Thank you.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!