ICoreWebView2.add_NewWindowRequested

Add an event handler for the NewWindowRequested event. NewWindowRequested runs when content inside the WebView requests to open a new window, such as through window.open. The app can pass a target WebView that is considered the opened window or mark the event as Handled, in which case WebView2 does not open a window. If either Handled or NewWindow properties are not set, the target content will be opened on a popup window.

If a deferral is not taken on the event args, scripts that resulted in the new window that are requested are blocked until the event handler returns. If a deferral is taken, then scripts are blocked until the deferral is completed or new window is set.

For more details and considerations on the target WebView to be supplied at the opened window, see ICoreWebView2NewWindowRequestedEventArgs::put_NewWindow.

\snippet AppWindow.cpp NewWindowRequested

interface ICoreWebView2
HRESULT
add_NewWindowRequested

Meta