错误/Web 控制台:未捕获类型错误:无法调用方法“getItem” http://m.youtube.com/:844 为 null

发布于 2024-11-03 14:45:22 字数 1271 浏览 0 评论 0原文

以下错误来自 Android (WebView),而不是直接来自我自己的代码:

04-28 12:36:15.174: ERROR/Web Console(7604): 
  Uncaught TypeError: Cannot call method 'getItem' of null at http://m.youtube.com/:844

除了将该 URL 加载到 WebView 之外,我实际上没有做任何特殊的事情。大多数时候我不会收到此错误,因此我假设这可能指向一些不可靠的网络条件?也许 youtube.com 太忙了?

很难说。无论如何,我至少想知道可能导致此问题的原因以及我是否可以捕获该错误,以便更好地处理它。

同样,我自己的代码不知道 getItem 是什么。另一方面,当发生此问题时,我的 WebView 上的 YouTube 页面只是

见解?

编辑:我一直在寻找有关提议的 WebSettings.setDomStorageEnabled(true) 的文档。到目前为止我能找到的唯一提示是 在此线程中:正如我之前提到的,这个问题很少发生,自从我发布问题以来就没有发生过。因此,我必须先了解一下它与“DOM 存储”之间的联系,然后才能设计出一种方法来测试/验证这是否可以解决问题。

另外,我刚刚遇到了另一条错误消息(看起来结果是良性的):

05-02 00:44:45.823: ERROR/Web Console(1595): 
  dojo.back.init() must be called before the DOM has loaded. 
  If using xdomain loading or djConfig.debugAtAllCosts, 
  include dojo.back in a build layer. 
  at http://sj.example.com/ncscript/subsect/j_gs/version/20110428191502.js:164

我现在可以看到与 DOM 的一些连接,所以看起来@Brian O'Dell 的方向是正确的。我只需要了解 WebSettings.setDomStorageEnabled(true) 的作用。

The following error comes from Android (WebView) and not directly from my own code:

04-28 12:36:15.174: ERROR/Web Console(7604): 
  Uncaught TypeError: Cannot call method 'getItem' of null at http://m.youtube.com/:844

I am really not doing anything special other than loading that URL into WebView. Most of the time I don't get this error, so I am assuming this could be pointing to some unreliable network conditions? Perhaps youtube.com too busy?

It's hard to tell. Regardless, I would like to at least have an idea what could be causing this and whether I can catch that error so that I can better handle it.

Again, my own code has no knowledge of what getItem is. On the other hand, when this problem occurs, the YouTube page on my WebView is simply empty.

Insights?

EDIT: I have been looking for documentation about the proposed WebSettings.setDomStorageEnabled(true). The only hint I have been able to find so far was in this SO thread: As I mentioned earlier, this problem occurs very rarely and haven't occurred since I posted my question. So I must understand a little more about the connection between this and "DOM storage" before I can devise a way to test/verify whether this solves the problem.

Also, I just encountered another error message (with benign results, so it seems):

05-02 00:44:45.823: ERROR/Web Console(1595): 
  dojo.back.init() must be called before the DOM has loaded. 
  If using xdomain loading or djConfig.debugAtAllCosts, 
  include dojo.back in a build layer. 
  at http://sj.example.com/ncscript/subsect/j_gs/version/20110428191502.js:164

I can now see some connection to DOM, so it looks like @Brian O'Dell is in the right direction. I just need to understand what WebSettings.setDomStorageEnabled(true) does.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧竹 2024-11-10 14:45:22

也许你需要类似的东西:

WebSettings 设置 = webView.getSettings();

settings.setDomStorageEnabled(true);

来源

Perhaps you need something like:

WebSettings settings = webView.getSettings();

settings.setDomStorageEnabled(true);

source

回眸一遍 2024-11-10 14:45:22

我在控制台中也遇到了同样的错误:

未捕获类型错误:无法调用 null 的“getItem”方法

我使用 localStorage.getItem 来检索值,因此我将其更改为 window.localStorage.getItem 并修复了问题

I also had the same error in the console:

Uncaught TypeError: unable to call null's 'getItem' method

I was using localStorage.getItem to retrieve the value, so I changed it to window.localStorage.getItem and fixed the problem

请持续率性 2024-11-10 14:45:22

我尝试将 localStorageChrome 自定义选项卡 一起使用,但遇到了相同的错误。我使用了 window.localstorage 而不是 localStorage ,问题得到了解决。

I was trying to use localStorage with Chrome Custom Tabs and I was getting the same error. I have used window.localstorage instead of localStorage and problem was solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文