WebView.NewWindowRequested WebView.NewWindowRequested WebView.NewWindowRequested WebView.NewWindowRequested Event

Definition

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

public : event TypedEventHandler<WebView, WebViewNewWindowRequestedEventArgs> NewWindowRequested
// Register
event_token NewWindowRequested(TypedEventHandler<WebView, WebViewNewWindowRequestedEventArgs> const& handler) const;

// Revoke with event_token
void NewWindowRequested(event_token const& cookie) const;

// Revoke with event_revoker
NewWindowRequested_revoker NewWindowRequested(auto_revoke_t, TypedEventHandler<WebView, WebViewNewWindowRequestedEventArgs> const& handler) const;
public event TypedEventHandler<WebView, WebViewNewWindowRequestedEventArgs> NewWindowRequested
Public Event NewWindowRequested As TypedEventHandler (Of WebView, WebViewNewWindowRequestedEventArgs)
<WebView NewWindowRequested="eventhandler"/>

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

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.

See also