Application made with Xamarin does not run Javascript

Asked

Viewed 172 times

1

I developed a small app with Webview in Xamarin, it correctly loads the page, but is not running Javascript, I’ve already enabled the Javascript with webView.Settings.JavaScriptEnabled = true; but unsuccessfully, I have no experience with Xamarin, I need to do something else?

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>

I get this error on the 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 answer

1


I decided, I put the following property:

webView.Settings.DomStorageEnabled = true;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.