DOM中的太多递归错误创建&删除脚本 [英] Too Much Recursion error in DOM Create & Remove Script

查看:49
本文介绍了DOM中的太多递归错误创建&删除脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Firebug正在报告过多的递归当我尝试在父母中创建一个尚不存在的子元素时。在继续创建子元素之前,脚本应自动创建缺少的父元素。在脚本应该使用新属性来调用自身以创建父项时,它会给我错误并且看起来它正在不断地循环该函数。


它似乎id:attrib [1] (第192行)没有被传递回createDOM()。因此,要么脚本无法自行调用,要么我在此代码中遗漏了某些内容。我尝试将attrib [1]设置为全局变量并将该变量传递给createDOM()的第二个实例,但这也不起作用。它应该在第二个实例中完全跳过这段代码,因为!parentExist在那时是假的。这部分代码运行的唯一原因是!parentExist和parent(attrib [1])!=''body'都是真的。有什么想法吗?

Firebug is reporting "too much recursion" when I attempt to create a child element in a parent that doesn''t exist yet. The script should automatically create the missing parent before going on to create the child element. At the point where the script is supposed to call itself with the new properties to create the parent, it gives me the error and looks like it''s looping the function continuously.

It seems that "id : attrib[1]" (line 192) is not being passed back into createDOM(). So, either a script cannot call itself, or I am missing something in this code. I tried setting attrib[1] to a global variable and passing the variable to the second instance of createDOM(), but that didn''t work either. It should entirely skip this section of code in the second instance because !parentExist is false at that point. The only reason this section of code runs is if !parentExist and parent (attrib[1]) != ''body'' are both true. Any ideas?

展开 | 选择 | Wrap | 行号

推荐答案

嗨...


起初只是一个小提示......你可以使用你用其他方式创建的对象''attrib'':

hi ...

at first a small hint ... you may use the object ''attrib'' that you have created an other way:

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号



因此,当您要检查属性值时,必须按名称引用而不是按索引引用...


i认为你的脚本不能正常工作......因为attrib [0]等总是未定义的......按照例子给你的方式重写你的代码...和它应该工作:)
so you have to refer by name instead of refering by index when you want to check a property value ...

i think your script is not working ... because attrib[0] etc. is always undefined ... rewrite your code the way the example shows you ... and it should work :)



啊哈!好的,再次感谢,gits。我今天稍后会试一试。你将从我身上找到一个专业的JS编码器。 = D

Aha! Okay, thanks again, gits. I will give this a try later on today. You''ll make an expert JS coder out of me yet. =D



啊哈!好的,再次感谢,gits。我今天稍后会试一试。你将从我身上找到一个专业的JS编码器。 = D
Aha! Okay, thanks again, gits. I will give this a try later on today. You''ll make an expert JS coder out of me yet. =D



:) ...如果您遇到更多问题,请回复...

:) ... post back in case you have more problems with it ...


这篇关于DOM中的太多递归错误创建&amp;删除脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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