I followed the post to create a custon WebView to interact with client JavaScript: https://docs.microsoft.com/es-es/xamarin/xamarin-forms/app-fundamentals/custom-renderer/hybridwebview
But when I try to load a page, for example https://www.google.es, the wevView shows an "ERROR_FILE_NOT_FOUND" loading the page "file:///android_asset/Content/https://www.google.es"
This the OnElementChanged of the HybridWebViewRenderer:
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
Control.RemoveJavascriptInterface("jsBridge");
((HybridWebView)Element).Cleanup();
}
if (e.NewElement != null)
{
Control.SetWebViewClient(new JavascriptWebViewClient($"javascript: {JavascriptFunction}"));
Control.AddJavascriptInterface(new JSBridge(this), "jsBridge");
Control.LoadUrl($"file:///android_asset/Content/{((HybridWebView)Element).Uri}");
}
}
Edited: It seems hybridWebView doesn't work with external pages!
Any suggestion?
LoadUrlmethod loads the HTML file that's specified by the HybridWebView.Uri property (index.html). The code specifies that the file is stored in the Asset>Content folder of the project. You could download the source file from the MS docs for reference. What do you want to do when you loadhttps://www.google.es? Perform the website in webview? - Wendy Zang - MSFTexternal websiteis a html file made by yourself? If yes, put it into Assets folder. It would call invokeCSharpAction to interact with javascript with this site. You could check the link to create web page. docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/… - Wendy Zang - MSFT