WebViewControlNewWindowRequestedEventArgs.NewWindow WebViewControlNewWindowRequestedEventArgs.NewWindow WebViewControlNewWindowRequestedEventArgs.NewWindow WebViewControlNewWindowRequestedEventArgs.NewWindow 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 : IWebViewControl NewWindow { get; set; }
IWebViewControl NewWindow();

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

Property Value

Additional features and requirements

Device family
Windows 10, version 1809 (introduced v10.0.17763.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v7)

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);