Skip to content

Open new BrowserWindow in the same renderer process #8959

Closed

Description

@seanchas116

Idea

It would be great if Electron can open new BrowserWindow with the same renderer process. It would make it easier to use subwindows in Electron, like native desktop apps.

Example

// Add function `popupBrowserWindow` that opens a BrowserWindow
// with the same renderer process
// like native window.open supported in sandboxed mode,
// but has full control of BrowserWindow
const popup = popupBrowserWindow("popup.html", {
  width: 800,
  height: 400,
  parent: remote.getCurrentWindow(),
  modal: true,
});
popup.window // => Window object of new window
popup.browserWindow // => Remote BrowserWindow of new window
popup.window.document.body.innerHTML = "<h1>Hello</h1>" // You can access its DOM directly

Benefits

Node integration

I'm not sure if newly opened windows can have Node integration, but it wouldn't be needed in use cases for dialogs or popups.

Activity

  1. tarruda commented on Mar 20, 2017

    @tarruda
    Contributor

    Why not use sandbox: true if you want native window.open API?

  2. seanchas116 commented on Mar 20, 2017

    @seanchas116
    ContributorAuthor

    Why not use sandbox: true if you want native window.open API?

    Because I also want to use full Node.js support including native addons in the renderer process.
    Probably you can proxy it via IPC but I think it would reduce convenience of Electron.

  3. tarruda commented on Mar 20, 2017

    @tarruda
    Contributor

    Right now sandbox mode supports the remote module, so you can probably use most node.js modules without much effort(require('electron').remote.require('module')). The fs module proxy is already available directly as require('fs') from the renderer, but we may add more modules.

  4. seanchas116 commented on Mar 20, 2017

    @seanchas116
    ContributorAuthor

    I still want to use Node modules directly - using all Node modules through remote.require would introduce some problems. For example if you add callbacks to remote objects and reload the window later, you'll have dangling callbacks and Electron will throw errors.

  5. changed the title [-]Feature request: open new BrowserWindow in the same renderer process[/-] [+]Open new BrowserWindow in the same renderer process[/+] on Mar 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions