WebViewControlNewWindowRequestedEventArgs.NewWindow プロパティ

定義

要求元 の 内からスクリプト呼び出しのwindow.openターゲットとして新しい WebViewControlWebViewControl提供します。 ターゲット Web ビューのコンテンツは、常にオープン Web ビュー内のコンテンツに対するクロスオリジンと見なされ、その逆も同様であり、クロスオリジンの制限の対象となります。 プロパティでNewWindow提供される はWebViewControl、opener Webview と同じプロセスで実行される新しいである必要があり、移動できません。 プロパティの設定は NewWindow 、 プロパティよりも Handled 優先されます。 が設定されている場合 NewWindow は、指定 WebViewControl された が使用されます。 が設定されていない場合 NewWindow は、 がチェックされ、 Handled 新しいウィンドウ要求の動作が決定されます。

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

プロパティ値

Windows の要件

デバイス ファミリ
Windows 10, version 1809 (10.0.17763.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v7.0 で導入)

次の C# サンプルは、window.open が opener に返される新しい WebViewControl の作成を許可されていることを示しています。

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

適用対象