Skip to content

window.open does not open anything when called from an iframe #10401

Closed

Description

@alexstrat
  • Electron version: 1.7.6

Actual behavior

When calling window.open from an iframe no popup is open whereas the new-window events is fired on the webContents.

Expected behavior

Would expect window.open to open a popup even in iframe.

Note that when using with nativeWindowOpen it works fine.

How to reproduce

Use this PR: alexstrat/electron-quick-start#1

screenshot 2017-08-30 18 06 40

Activity

  1. changed the title [-]window.open does not open anything when calling from an iframe[/-] [+]window.open does not open anything when called from an iframe[/+] on Aug 30, 2017
  2. MarshallOfSound commented on Aug 30, 2017

    @MarshallOfSound
    Member

    As far as I am aware this is expected behavior as preload scripts do not currently run in iframes. I believe our long term plan is to make nativeWindowOpen default to true (when we're happy everything works) and then this will not be an issue 👍

  3. alexstrat commented on Aug 30, 2017

    @alexstrat
    ContributorAuthor

    Ok, yes indeed was wandering around and realized as well that nativeWindowOpen is actually the future and the solution of this.

    I wished I could use nativeWindowOpen but can't because of #8100 😅

    However, in several cases (window.alert..), it looks like we could benefit from having preload running in iframes. Isn't that conceivable? (Relates to #1044 I guess.)

  4. TIM0N commented on Sep 28, 2017

    @TIM0N

    I have a similar Problem, not sure if its the same.

    ProjectDescription:
    In render i have main page index.html which holds -> multiple webviews (webpreferences="nativeWindowOpen=yes") -> contain random content including iframes -> iframes include links or call window.open()

    In index.html script I listen on new-window event like this:

    webview.getWebContents().on('new-window', (event, url) => {
                    event.preventDefault();
                    shell.openExternal(url);
    });
    

    Problem:
    When i build the app against electron v1.6.14 its fine, but with v1.7.5 or higher the 'new-window' event is not triggered.

    Sadly i could not find what changes are responsible for breaking this behavior or how to fix it. I wonder if the above means, that there is no fix or did i miss something?

  5. sofianguy commented on Jan 8, 2019

    @sofianguy
    Contributor

    Thank you for taking the time to report this issue and helping to make Electron better.

    The version of Electron you reported this on has been superseded by newer releases.

    If you're still experiencing this issue in Electron v2.0.x or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

    I'm setting the blocked/need-info label for the above reasons.

    Thanks in advance! Your help is appreciated.

  6. added
    blocked/need-info ❌
    on Jan 8, 2019
  7. sofianguy commented on Jan 15, 2019

    @sofianguy
    Contributor

    Thank you for your issue!

    We haven't gotten a response to our questions in our comment above. With only the information that is currently in the issue, we don't have enough information to take action. I'm going to close this but don't hesitate to reach out if you have or find the answers we need, we'll be happy to reopen the issue.

  8. added 5 commits that reference this issue on Jan 17, 2019
    f5a166d
    aadee6c
    58a6fe1
    f883aa0
    0890b0c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked/need-info ❌bug 🪲version/1.7.x

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions