1

Desenvolvi um pequeno aplicativo com WebView no Xamarin, ele carrega corretamente a página, porém não está executando JavaScript, já habilitei o JavaScript com webView.Settings.JavaScriptEnabled = true; mas sem sucesso, não tenho experiência alguma com Xamarin, preciso fazer mais alguma coisa?

MainActivity.cs

[Activity(MainLauncher = true, Theme = "@android:style/Theme.NoTitleBar.Fullscreen")]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            var webView = FindViewById<WebView>(Resource.Id.webView);

            // Use subclassed WebViewClient to intercept hybrid native calls
            webView.SetWebViewClient(new HybridWebViewClient());
            webView.Settings.JavaScriptCanOpenWindowsAutomatically = true;
            webView.Settings.JavaScriptEnabled = true;
            webView.LoadUrl("http://financas.gopagoda.io");


        }

        private class HybridWebViewClient : WebViewClient
        {
            public override bool ShouldOverrideUrlLoading(WebView webView, string url)
            {

                // If the URL is not our own custom scheme, just let the webView load the URL as usual
                var scheme = "hybrid:";

                if (!url.StartsWith(scheme))
                    return false;

                // This handler will treat everything between the protocol and "?"
                // as the method name.  The querystring has all of the parameters.
                var resources = url.Substring(scheme.Length).Split('?');
                var method = resources[0];
                var parameters = System.Web.HttpUtility.ParseQueryString(resources[1]);

                return true;
            }
        }
    }

Main.axml

<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"

        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webView" >
</WebView>

Recebo esse erro no console:

"jQuery.Deferred exception: Cannot read property 'getItem' of null", source: http://financas.gopagoda.io/js/all.js (2) [INFO:CONSOLE(2)] "Uncaught TypeError: Cannot read property 'getItem' of null", source: http://financas.gopagoda.io/js/all.js

1 Resposta 1

1

Resolvi, coloquei a seguinte propriedade:

webView.Settings.DomStorageEnabled = true;

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .