void OnNavigating(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationStartingEventArgs args) { var uri = args.Uri != null ? args.Uri.AbsoluteUri : ""; NavigationRequestedDelegate nrd = (NavigationRequestedDelegate)Element.InvokeEvent(WebViewEventType.NavigationRequested, new NavigationRequestedDelegate(Element, uri)); args.Cancel = nrd.Cancel; }
/// <summary> /// You can cancel a URL from being loaded by returning a delegate with the cancel boolean set to true. /// </summary> private NavigationRequestedDelegate OnNavigationStarted(NavigationRequestedDelegate eventObj) { if (eventObj.Uri == "www.somebadwebsite.com") { eventObj.Cancel = true; } return(eventObj); }
public override void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action <WKNavigationActionPolicy> decisionHandler) { NavigationRequestedDelegate res = (NavigationRequestedDelegate)Element.InvokeEvent(WebViewEventType.NavigationRequested, new NavigationRequestedDelegate(Element, navigationAction.Request.Url.ToString())); if (res.Cancel) { decisionHandler(WKNavigationActionPolicy.Cancel); } else { decisionHandler(WKNavigationActionPolicy.Allow); } }