Skip to content

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

Open
@aquinn39

Description

@aquinn39

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions