的WebView导致未捕获的类型错误加载时www.google.com加载、错误、类型、WebView

2023-09-13 01:39:54 作者:男人就应该有气质 つ

我使用web视图加载并呈现各种没有问题的网站。奇怪的是,一个似乎会导致错误是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:ERROR / Web控制台(3721):未捕获的类型错误:不能调用方法'的getItem空的的 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

我启用JavaScript(除其他事项外)在我的onResume覆盖:

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(真);

这似乎让浏览器来存储页面元素的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.