void OnNavigated(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { var uri = args.Uri != null ? args.Uri.AbsoluteUri : ""; Element.SetValue(FormsWebView.SourceProperty, uri); Element.InvokeEvent(WebViewEventType.NavigationComplete, new NavigationCompletedDelegate(Element, uri, args.IsSuccess)); }
/// <summary> /// Called when the UWP WebView event NavigationCompleted has been sent. /// </summary> /// <param name="sender">sender object</param> /// <param name="args">event args</param> private void OnNavigationCompleted( Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { if (this.Element.Source is HtmlWebViewSource) { this.Element.SendNavigated( new WebNavigatedEventArgs( WebNavigationEvent.NewPage, this.Element.Source, "about:blank", // no URL available args.IsSuccess ? WebNavigationResult.Success : WebNavigationResult.Failure)); } }
private async void OnNavigated(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { await Control.InvokeScriptAsync("eval", new[] { WebViewControlDelegate.InjectedFunction }); foreach (var key in Element.GetAllCallbacks()) { await Control.InvokeScriptAsync("eval", new[] { WebViewControlDelegate.GenerateFunctionScript(key) }); } var uri = args.Uri != null ? args.Uri.AbsoluteUri : ""; Element.SetValue(FormsWebView.UriProperty, uri); Element.InvokeEvent(WebViewEventType.NavigationComplete, new NavigationCompletedDelegate(Element, uri)); }
private void Control_NavigationCompleted(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { var httpBaseProtocolFilter = new HttpBaseProtocolFilter(); var cookieManager = httpBaseProtocolFilter.CookieManager; var cookieCollection = cookieManager.GetCookies(args.Uri); var cookies = new CookieCollection(); foreach (var cookie in cookieCollection) { cookies.Add(new Cookie() { Domain = cookie.Domain, HttpOnly = cookie.HttpOnly, Name = cookie.Name, Path = cookie.Path, Secure = cookie.Secure, Value = cookie.Value, }); } CookieWebView.OnNavigated(new CookieNavigatedEventArgs() { Url = args.Uri.ToString(), Cookies = cookies }); }
private void NavigationCompleted(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { Element.OnNavigationCompleted(sender, args.Uri.AbsoluteUri); }
private async void OnWebViewNavigationCompleted(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { if (!args.IsSuccess) { return; } await Control.InvokeScriptAsync("eval", SetBodyOverFlowHiddenString); var heightString = await Control.InvokeScriptAsync("eval", new[] { "document.body.scrollHeight.toString()" }); if (int.TryParse(heightString, out int height)) { //await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { //Debug.WriteLine($"OnWebViewNavigationCompleted - {height}"); Element.HeightRequest = height + 40; //}); } //var widthString = await Control.InvokeScriptAsync("eval", new[] { "document.body.scrollWidth.toString()" }); //if (int.TryParse(widthString, out int width)) //{ // Element.WidthRequest = width; //} }
private static void WebView_NavigationCompleted(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { var message = $"NavigationCompleted @ {args.Uri} [{sender.Source}]"; SetMessage(sender, message); sender.Log().DebugIfEnabled(() => message); }
private async void WebView_NavigationCompleted(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { string docClickScript = @"if (document.addEventListener) {" + "document.addEventListener(\"click\", PageClicked, false);" + "} else {" + "document.attachEvent('onclick', PageClicked);" + "} " + "function PageClicked(event){" + "var pointX = event.clientX;" + "var pointY = event.clientY;" + " window.external.notify('tap:' + pointX + ':' + pointY);" + "}"; await sender.InvokeScriptAsync("eval", new string[] { docClickScript }); //set event 'click' on page RingContentVisibility = false; RingText = screeningText; }
private static async void Browser_NavigationCompleted(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { await sender.InvokeScriptAsync("eval", new[] { DisableScrollingJs }); }
private async void OnWebNavigationCompleted(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { while (NotificationIds.Count > 0) { Context.HideProgress(NotificationIds[0]); NotificationIds.RemoveAt(0); } if (!args.Uri.ToString().StartsWith(VkAuthorization.GetRedirectUrl())) { return; } await TryFinishAuthorizationAsync(args.Uri); }
private async void Control_NavigationCompleted(Windows.UI.Xaml.Controls.WebView sender, Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs args) { await sender.InvokeScriptAsync("eval", new string[] { "window.alert = function(message){ window.external.notify(message); };" }); }