Skip to content

[webview] window.open throw errors even when new-window events are handled #1864

Closed

Description

@felicienfrancois

When calling window.open in a webview that handles new-window events, I still get the following error, even if the new window is successfully handled.

It is not allowed to open new window from this WebContents
webview.addEventListener('new-window', function(e) {
 // something here that open the new window
});

Activity

  1. frankhale commented on Jun 4, 2015

    @frankhale
    Contributor

    I was getting this as well but this is fixed in master by #1850 if my
    memory serves me correctly.

    On Thu, Jun 4, 2015, 07:41 Félicien FRANCOIS [email protected]
    wrote:

    When calling window.open in a webview that handles new-window events, I
    still get the following error, even if the new window is successfully
    handled.

    It is not allowed to open new window from this WebContents

    webview.addEventListener('new-window', function(e) {
    // something here that open the new window
    });

    —
    Reply to this email directly or view it on GitHub
    #1864.

  2. deepak1556 commented on Jun 18, 2015

    @deepak1556
    Member

    @zcbenz what is the expected behaviour here ? should we emit the event, even if there is no window creation

  3. zcbenz commented on Jun 19, 2015

    @zcbenz
    Contributor

    @deepak1556 It should emit the new-window event, but there were some implementation problems since you can not send synchronous messages from webview to host.

  4. felicienfrancois commented on Jun 23, 2015

    @felicienfrancois
    Author

    @frankhale this is not fixed yet. Still happening in 0.28.3

  5. frankhale commented on Jun 23, 2015

    @frankhale
    Contributor

    Looks like I was wrong. I just went back to check my own app. This issue has not been closed so it's all good.

  6. kjlaw89 commented on Jun 24, 2015

    @kjlaw89

    @zcbenz Would it be possible to tag webviews to have the capability to open new windows with window.open in the same way that the BrowserWindow can? Maybe a new tag on webview like "allow-popups" or something? If it's not specified then you'd fall back onto the new-window event (or possible do both if that attribute is provided).

    This would be useful for us, since we have quite a few places in our code that do window.open () with various settings and right now we're getting the same message @felicienfrancois was getting:

    It is not allowed to open new window from this WebContents
    
  7. felicienfrancois commented on Jun 24, 2015

    @felicienfrancois
    Author

    @kjlaw89 this tag could also be automatically toggled when adding an event listener to window-open.

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