的WebView导致未捕获的类型错误加载时www.google.com [英] WebView causing Uncaught TypeError when loading www.google.com

查看:249
本文介绍了的WebView导致未捕获的类型错误加载时www.google.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用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.

这篇关于的WebView导致未捕获的类型错误加载时www.google.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆