Skip to content

Support window.open() #5043

Description

@z3db0y

Is your feature request related to a problem? Please describe.

Wails v3 is coming with multi-window support, however if a window is opened by the frontend using a web API such as window.open(), it doesn't seem to propagate to the backend.

Describe the solution you'd like

Handle windows opened by the webkit context and allow setting their options and size prior to them being displayed, similar to application.Window.NewWithOptions; something like:

application.Window.OnCreate(func (url string) {
   // setup new window manually
})

Describe alternatives you've considered

The only alternative to this is sending a request to open a window to the backend, and in my case the windows would like to communicate using postMessage(), so that is not a solution for me.

Additional context

Currently, window.open() seems to simply open a default webview2 window (with the URL bar and default menu key mappings).

Activity

  1. leaanthony commented on Mar 15, 2026

    @leaanthony
    Member

    I'm not sure it's possible to intercept the webview's open function. Have you tried?

  2. yusnelgg commented on Mar 25, 2026

    @yusnelgg

    Hi.

    In my case, this is the closest I've come to intercepting window.open() in Go. It's a small proof of concept using WebView2, where the main window intercepts window.open() and binds it to _blank, opening the child windows as separate processes. This keeps the main window active while still allowing some control over the new windows.

    You can see it here: https://github.com/yusnelgg/window-open-intercept-go

    This is mostly for reference and experimentation.

  3. github-actions commented on Aug 3, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity.
    It will be closed if no further activity occurs within the next 10 days.

    If this issue is still relevant, please add a comment to keep it open.
    Thank you for your contributions.

  4. added
    staleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closed
    on Aug 3, 2026
  5. midagedev commented on Aug 29, 2026

    @midagedev
    Contributor

    Measured data for this issue on macOS, v3.0.0-beta.15 (three runs, consistent), from a minimal application.New + one WebviewWindow app whose page reports back over a loopback HTTP channel:

    • window.open('https://example.com') returns null
    • a programmatic click on <a target="_blank"> leaves location unchanged 3s later; the page stays alive
    • in-app window count stays at 1 (200ms poll over app windows)
    • no system-browser reaction: browser process sets unchanged, and with the target swapped for a loopback tripwire server, zero requests arrived — so not even a tab in an already-running browser
    • caveat: the click/window.open had no user gesture; but the mechanism is source-level — at master 9d49e8e, webview_window_darwin.m:993-994 implements exactly one WKUIDelegate method (runOpenPanelWithParameters); createWebViewWithConfiguration appears nowhere in the module, and without it WKWebView drops the request silently. On Windows the NewWindowRequested COM event exists only as generated interop (internal/webview2/.../corewebview2.go), never subscribed in pkg/application; Linux registers no create handler.

    So the three platforms currently do three different things with the same click: macOS silently nothing, Windows a default-chrome WebView2 popup (as described above), Linux nothing.

    Production context: our app (gadak) works around this with an HTTP endpoint the frontend calls to open URLs in the system browser — exactly the kind of interception a Window.OnCreate(url)-style hook (or an OnNewWindow(url) NewWindowAction option with an OpenInSystemBrowser default) would replace.

    If the shape proposed in this issue is acceptable to the maintainers, I'd be glad to contribute the darwin implementation (delegate method + hook plumbing), in the vein of #6008.

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

    EnhancementNew feature or requestLinuxMacOSP2Medium priorityWindowsawaiting feedbackMore information is required from the requestorstaleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closedv3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions