错误/Web 控制台:未捕获类型错误:无法调用方法“getItem” http://m.youtube.com/:844 为 null
以下错误来自 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许你需要类似的东西:
来源
Perhaps you need something like:
source
我在控制台中也遇到了同样的错误:
我使用
localStorage.getItem
来检索值,因此我将其更改为window.localStorage.getItem
并修复了问题I also had the same error in the console:
I was using
localStorage.getItem
to retrieve the value, so I changed it towindow.localStorage.getItem
and fixed the problem我尝试将
localStorage
与Chrome 自定义选项卡
一起使用,但遇到了相同的错误。我使用了window.localstorage
而不是localStorage
,问题得到了解决。I was trying to use
localStorage
withChrome Custom Tabs
and I was getting the same error. I have usedwindow.localstorage
instead oflocalStorage
and problem was solved.