Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.83 KB

webview_newwindowrequested.md

File metadata and controls

51 lines (36 loc) · 1.83 KB
-api-id -api-type
E:Windows.UI.Xaml.Controls.WebView.NewWindowRequested
winrt event

Windows.UI.Xaml.Controls.WebView.NewWindowRequested

-description

Occurs when a user performs an action in a WebView that causes content to be opened in a new window.

-xaml-syntax

<WebView NewWindowRequested="eventhandler"/>

-remarks

See WebViewNewWindowRequestedEventArgs.

This event occurs only for user initiated actions. By default, when a user clicks a link in a WebView that requests to open in a new window, the link launches the default browser. A new window can be caused by the user clicking on an href, or a button which calls window.open.

Handle this event to provide custom handling of the new window request. You might navigate the WebView to the desired page, or create a new WebView in your app to display the requested content. If you provide custom handling of the new window request, set the Handled property to true to prevent the default browser from being launched.

-examples

<WebView x:Name="myWebView" NewWindowRequested="OnNewWindowRequested" /> 
private void OnNewWindowRequested (WebView sender, WebViewNewWindowRequestedEventArgs e) 
{ 
    if (e.Referrer.Host == "www.contoso.com") 
    { 
         var newWebView = new WebView(); 
         newWebView.Navigate(e.Uri); 
         myGrid.Children.Add(newWebView); 
         e.Handled = true; 
    } 
} 

-see-also

WebViewNewWindowRequestedEventArgs