12

Im using WebView to embed a third party website into an app.

mWebView = (WebView) findViewById(R.id.activity_main_webview);
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient());
mWebView.loadUrl("http://someurl.com/");

The problem is WebView freezes as it finds javascript errors:

I/chromium﹕ [INFO:CONSOLE(7178)] "Uncaught TypeError: Cannot read property 'getItem' of null"

but somehow in the browser (Android), it loads perfectly.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Martha
  • 1,070
  • 1
  • 12
  • 29

1 Answers1

19

Try to use setDomStorageEnabled(true)

WebSettings settings = webView.getSettings();

settings.setDomStorageEnabled(true);
Bruce Lan
  • 347
  • 2
  • 6
  • [http://stackoverflow.com/questions/4930623/webview-causing-uncaught-typeerror-when-loading-www-google-com](http://stackoverflow.com/questions/4930623/webview-causing-uncaught-typeerror-when-loading-www-google-com) – Bruce Lan Sep 11 '15 at 19:24
  • Thanks a lot I din't know what was causing my webview to not load and this helped me – magorich Sep 01 '16 at 00:35