本文介绍了Javascript DOM“这个”对象不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人可以解释followig错误信息?
我试图获得关于mutiple div的简单信息,而其中一个引发了这个错误。



  resource:// gre / modules / devtools / server /actors/script.js 

我使用的代码是:

  var elem = document.getElementById(id); 
ret ['left'] = Math.round(elem.offsetLeft); //elem.offsetLeft返回null

我以前没有看到这样的错误,找不到关于这个问题的任何信息。如果有人可以告诉我,我做错什么会很棒。

解决方案

@ felix-king是正确的,这个是一个firefox devtools错误。通常当您检查对象并且打开比正在检查的实例的类型低的基本原型树节点时,会发生这种情况。所以这解释了@ jfriend00在评论中提到的这个错误问题,即使你在代码中没有引用this,检查器也可以。


Is there anybody who can explain the followig error message?I'm trying to get simple informations about mutiple divs while one of them throws this error.

resource://gre/modules/devtools/server/actors/script.js

The Code i'm using is:

var elem = document.getElementById(id);
ret['left'] = Math.round(elem.offsetLeft); //elem.offsetLeft returns null

I haven't seen such an error before and can't find any information about this problem. It would be great if somebody could tell me, what i'm doing wrong.

解决方案

@felix-king is correct, this is a firefox devtools errors. It usually happens when you inspect an object and you open a base prototype tree node lower than the type of the instance you are inspecting. So this explains the "this" error problem that @jfriend00 refers to in the comment, even though you don't reference "this" in your code, the Inspector does.

这篇关于Javascript DOM“这个”对象不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 13:37