Android API 23. WebView如何忽略javascript错误 [英] Android API 23. WebView how to ignore javascript errors
本文介绍了Android API 23. WebView如何忽略javascript错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用WebView将第三方网站嵌入到应用程序中.
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/");
问题是WebView在发现javascript错误时冻结:
The problem is WebView freezes as it finds javascript errors:
I/chromium:[INFO:CONSOLE(7178)]未捕获的TypeError:无法读取null的属性'getItem'"
I/chromium﹕ [INFO:CONSOLE(7178)] "Uncaught TypeError: Cannot read property 'getItem' of null"
但是以某种方式在浏览器(Android)中,它可以完美加载.
but somehow in the browser (Android), it loads perfectly.
推荐答案
尝试使用 setDomStorageEnabled(true)
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);
这篇关于Android API 23. WebView如何忽略javascript错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文