Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

404
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda