WebViewControlNewWindowRequestedEventArgs.NewWindow Property

Definition

Provides a new WebViewControl as the target for a window.open script call from inside the requesting WebViewControl. The content in target webview is always considered cross-origin to the content in opener webview and vice versa and subject to cross-origin restrictions. The WebViewControl provided in the NewWindow property must be new, running on the same process as the opener webview and cannot have been navigated. Setting the NewWindow property takes priority over the Handled property. If NewWindow is set, then the provided WebViewControl is used. If NewWindow is not set, then Handled is checked to determine behavior for the new window request.

public:
 property IWebViewControl ^ NewWindow { IWebViewControl ^ get(); void set(IWebViewControl ^ value); };
IWebViewControl NewWindow();

void NewWindow(IWebViewControl value);
public IWebViewControl NewWindow { get; set; }
var iWebViewControl = webViewControlNewWindowRequestedEventArgs.newWindow;
webViewControlNewWindowRequestedEventArgs.newWindow = iWebViewControl;
Public Property NewWindow As IWebViewControl

Property Value

Windows requirements

Device family
Windows 10, version 1809 (introduced in 10.0.17763.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v7.0)

Examples

The following C# sample demonstrates window.open being allowed to create a new WebViewControl that is returned to opener:

WebViewControlProcess wvProc;
WebViewControl webView;

void OnWebViewControlNewWindowRequested(WebViewControl sender, WebViewControlNewWindowRequestedEventArgs args)
{

    if (args.Uri.Domain == “mydomain.com”)
    {
        using deferral = args.GetDeferral();
        args.NewWindow = await wvProc.CreateWebViewControlAsync(
            parentWindow, targetWebViewBounds);
        deferral.Complete();
    }
    else
    {
        // Prevent WebView from launching in the default browser.
        args.Handled = true;
    }
}

String htmlContent = “<html><script>window.open(‘http://mydomain.com’)</script><body></body></html>”;

webView.NavigateToString(htmlContent);

Applies to