Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        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);
            }
        }