加载 www.google.com 时 WebView 导致 Uncaught TypeError [英] WebView causing Uncaught TypeError when loading www.google.com
问题描述
我正在使用 WebView 加载和呈现各种网站,没有任何问题.奇怪的是,似乎导致错误的是 www.google.com
I'm using WebView to load and render a variety of websites with no problem. Oddly, the one that seems to cause errors is www.google.com
加载此页面时,单击搜索"按钮不起作用.当它被点击时,我在 LogCat 中看到了这个错误(我在页面加载过程中也看到了 3 个类似的错误报告):
When loading this page, the Search button does not work when clicked. When it is clicked, I see this error in LogCat (I also see 3 similar errors reported during the page load):
02-07 23:23:59.230:错误/Web 控制台(3721):未捕获的类型错误:无法在 http://www.google.com/:342
02-07 23:23:59.230: ERROR/Web Console(3721): Uncaught TypeError: Cannot call method 'getItem' of null at http://www.google.com/:342
我在 onResume 覆盖中启用 JavaScript(除其他外):
I am enabling JavaScript (among other things) in my onResume override:
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setDatabaseEnabled(true);
知道是什么导致了这些错误吗?谢谢!
Any idea what could be causing these errors? Thanks!
推荐答案
我发现了关键电话:
settings.setDomStorageEnabled(true);
这似乎允许浏览器存储页面元素的 DOM 模型,以便 Javascript 可以对其进行操作.
This seems to allow the browser to store a DOM model of the page elements, so that Javascript can perform operations on it.
这篇关于加载 www.google.com 时 WebView 导致 Uncaught TypeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!