Skip to content

Instantly share code, notes, and snippets.

@Gvozd
Created July 4, 2018 09:37
Show Gist options
  • Select an option

  • Save Gvozd/2cec0c8c510a707854e439fb15c561b0 to your computer and use it in GitHub Desktop.

Select an option

Save Gvozd/2cec0c8c510a707854e439fb15c561b0 to your computer and use it in GitHub Desktop.
Facebook, OAuth login. Correct opener in window
We couldn’t find any files to show.
@sanoopjose

Copy link
Copy Markdown

It will be great if you could add the new window implementation inside the 'new-window' event handler.

mainWindow.webContents.on('new-window', function (e, url, frameName, disposition, options) {
  options.webPreferences.affinity = 'main-window';
Object.assign(options, {
      width: 100,
      height: 100
    })
    e.newGuest = new BrowserWindow(options)
});

It seems like the above code is not working.

@Gvozd

Gvozd commented Feb 11, 2019

Copy link
Copy Markdown
Author

This worked(in your example, prevention is forgotten):

mainWindow.webContents.on('new-window', function (e, url, frameName, disposition, options) {
    options.webPreferences.affinity = 'main-window';
    Object.assign(options, {
      width: 100,
      height: 500
    })
    // not really need uncomment next lines. not sure, but navigation(in child window) may break, or something else
    // e.newGuest = new BrowserWindow(options)
    // e.preventDefault();
  });

I also want to note that the workaround works only in the electron@2
In my last tests, this solution not actually worked at electron@3-4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment