Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android API 23. WebView how to ignore javascript errors

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.

like image 801
Martha Avatar asked Sep 11 '15 18:09

Martha


1 Answers

Try to use setDomStorageEnabled(true)

WebSettings settings = webView.getSettings();

settings.setDomStorageEnabled(true);
like image 111
Bruce Lan Avatar answered Sep 17 '22 16:09

Bruce Lan