Javascript DOM“这个”对象不正确
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27159967/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript DOM "this" Object is incorrect
提问by BeMoreDifferent.com
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.
有没有人可以解释followig错误消息?我正在尝试获取有关多个 div 的简单信息,而其中一个会引发此错误。
Ignoring get or set of property that has [LenientThis] because the "this" object is incorrect. (script.js:3288)
忽略具有 [LenientThis] 的 get 或 set 属性,因为“this”对象不正确。(script.js:3288)
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.
我以前从未见过这样的错误,也找不到有关此问题的任何信息。如果有人能告诉我,我做错了什么,那就太好了。
采纳答案by rickdog
@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.
@felix-king 是正确的,这是一个 firefox devtools 错误。当您检查对象并打开低于您正在检查的实例类型的基础原型树节点时,通常会发生这种情况。所以这解释了@jfriend00 在评论中提到的“this”错误问题,即使您没有在代码中引用“this”,Inspector 也会。