Search code examples
javascripthtmlelectronchromiumwindow.open

How to keep multiple subwindows open in Electron?


My app structure overview:

Currently, when opening multiple subwindows, the later opened will replace the former opened, how to keep them all open, instead of replacing each other?


Solution

  • Update: in Electron 15, nativeWindowOpen defaults to true.


    You should enable nativeWindowOpen on your main window.

    new BrowserWindow({ webPreferences: { nativeWindowOpen: true } })
    

    Then, each window.open call (assuming you aren't using the same window name, not counting special window names like '_blank') will open a brand new window.