Skip to content

[Feature]: Allow more control over the window that appears when a webpage uses window.open #5254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aquinn39 opened this issue May 25, 2025 · 2 comments
Assignees
Labels
feature request feature request

Comments

@aquinn39
Copy link

Describe the feature/enhancement you need

When a webpage opens a new window using window.open, the WebView2 defaults to open a new window which it creates and handles, similar to in MS Edge. Developers can override this behaviour in the WebView2 so that they can provide their own behaviour. However, it would be really advantageous if we could just have some customisability over the default window, so that we don't have to create our own window from scratch just to change one thing or be subscribe to an event. At the moment it kind of feels like a rouge window that, despite technically being part of the developer's app, they have no control over.

Perhaps the NewWindowRequested args could give us a WebView2 object for the default window, or some other object we could use to interface with it?

This is the window I am referring to:

Image

The scenario/use case where you would use this feature

Specifically, this came to mind as I have an app with a WebView2 in a WPF app which has TopMost set to true on the window which uses it, and when the webpage opens a new window, the new window appears behind the app's window due to it not inheriting TopMost. If I could control whether the external window was TopMost, or could detect when the window opens and disable TopMost on my window until the new window closes, that would fix this issue.

Of course, there could be plenty of use cases for this, such as customising the window, responding to certain events to enable custom behaviour, etc. without the need to create a new window manually (may as well reuse the one that is already created).

How important is this request to you?

Nice to have. There are other ways to tackle this, but having official API support would be beneficial.

Suggested implementation

No response

What does your app do? Is there a pending deadline for this request?

No response

@aquinn39 aquinn39 added the feature request feature request label May 25, 2025
@sivMSFT
Copy link

sivMSFT commented May 26, 2025

Thank you @aquinn39 for bringing this up. Could you share, how are you currently tackling this?

@aquinn39
Copy link
Author

@sivMSFT At the moment the solution is to create a custom window and apply the attributes to it specified in the NewWindowRequested event arguments, which is fine, I just thought since the WebView2 has the behaviour for showing web windows built-in, may as well use that if it's available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request feature request
Projects
None yet
Development

No branches or pull requests

3 participants