DOM异常:HIERARCHY_REQUEST_ERR(3)错误

时间:2022-11-20 20:28:58

The following code works fine in chrome and Firefox, but breaks in IE 9.0.

下面的代码在chrome和Firefox中运行良好,但在IE 9.0中被打破。

message.nodeTree.childNodes[1].childNodes[0].childNodes[0].appendChild(pkf_util.createXmlTextNode(text));

message.nodeTree.childNodes[1]childnodes[0]childnodes[0].appendChild(pkf_util.createXmlTextNode(文本);

when I try to input something via textarea,it comes with SCRIPT5022:

当我尝试通过textarea输入内容时,它带有SCRIPT5022:

DOM Exception: HIERARCHY_REQUEST_ERR (3) line 481 character 29;

DOM异常:HIERARCHY_REQUEST_ERR(3)第481行字符29;

Any ideas why it's not working in IE 9.0?

你知道为什么它在IE 9。0中不工作吗?

3 个解决方案

#1


9  

I know its a long time since the Q was asked but I reached it based on the error message. specifically in my case I was getting the following error: "HIERARCHY_REQUEST_ERR: DOM Exception 3: A Node was inserted somewhere it doesn't belong.".

我知道问Q已经有很长时间了,但是我是基于错误消息到达的。在我的例子中,我得到了以下错误:“HIERARCHY_REQUEST_ERR: DOM异常3:一个节点被插入了它不属于的位置。”

I was trying to append a node that I was creating using jquery to some other node in my html document. It turned out that by mistake I used $('div') instead of $('<div>') for the creating the new (appended) node.

我试图将使用jquery创建的节点附加到html文档中的其他节点。结果证明,我错误地使用了$('div')而不是$('

')来创建新的(附加的)节点。

I hope this will help someone in the future.

我希望这对未来的人有所帮助。

#2


0  

This can be a solution...

这可以是一个解决方案……

var element = document.createElement('iframe');
element.src = url;
document.getElementsByTagName('body')[0].appendChild(element);    

Good luck

祝你好运

#3


0  

DOM exception 3 means you've tried to insert an element to a place in the DOM where it doesn't belong. (ref.)

DOM exception 3表示您试图将元素插入到DOM中不属于它的位置。(ref)。

Possible causes:

可能的原因:

  • IE9 doesn't consider the XML node created by the library a valid DOM node.
  • IE9不认为由库创建的XML节点是有效的DOM节点。
  • The node created is a valid DOM node but it's being appended somewhere it doesn't belong (such as anything being appended to a node that's supposed to be a leaf)
  • 创建的节点是一个有效的DOM节点,但是它被附加到它不属于的地方(比如任何被附加到应该是叶子的节点上的东西)
  • The node created is not actually a new element, but rather a parent of the node being appended to. This would classify as a bug in the library.
  • 创建的节点实际上不是一个新元素,而是被附加到的节点的父节点。这将被归类为库中的一个bug。
  • If you try to append a null anywhere, you're practically asking for a DOM exception. Perhaps your library fails on IE9?
  • 如果您试图在任何地方附加一个null,实际上就是在请求DOM异常。也许你的库在IE9上失败了?

Google search on pkf_util returns ... this question, so we cannot rule out a bug in pkf_util.

谷歌搜索pkf_util返回…这个问题,我们不能排除pkf_util中的错误。

#1


9  

I know its a long time since the Q was asked but I reached it based on the error message. specifically in my case I was getting the following error: "HIERARCHY_REQUEST_ERR: DOM Exception 3: A Node was inserted somewhere it doesn't belong.".

我知道问Q已经有很长时间了,但是我是基于错误消息到达的。在我的例子中,我得到了以下错误:“HIERARCHY_REQUEST_ERR: DOM异常3:一个节点被插入了它不属于的位置。”

I was trying to append a node that I was creating using jquery to some other node in my html document. It turned out that by mistake I used $('div') instead of $('<div>') for the creating the new (appended) node.

我试图将使用jquery创建的节点附加到html文档中的其他节点。结果证明,我错误地使用了$('div')而不是$('

')来创建新的(附加的)节点。

I hope this will help someone in the future.

我希望这对未来的人有所帮助。

#2


0  

This can be a solution...

这可以是一个解决方案……

var element = document.createElement('iframe');
element.src = url;
document.getElementsByTagName('body')[0].appendChild(element);    

Good luck

祝你好运

#3


0  

DOM exception 3 means you've tried to insert an element to a place in the DOM where it doesn't belong. (ref.)

DOM exception 3表示您试图将元素插入到DOM中不属于它的位置。(ref)。

Possible causes:

可能的原因:

  • IE9 doesn't consider the XML node created by the library a valid DOM node.
  • IE9不认为由库创建的XML节点是有效的DOM节点。
  • The node created is a valid DOM node but it's being appended somewhere it doesn't belong (such as anything being appended to a node that's supposed to be a leaf)
  • 创建的节点是一个有效的DOM节点,但是它被附加到它不属于的地方(比如任何被附加到应该是叶子的节点上的东西)
  • The node created is not actually a new element, but rather a parent of the node being appended to. This would classify as a bug in the library.
  • 创建的节点实际上不是一个新元素,而是被附加到的节点的父节点。这将被归类为库中的一个bug。
  • If you try to append a null anywhere, you're practically asking for a DOM exception. Perhaps your library fails on IE9?
  • 如果您试图在任何地方附加一个null,实际上就是在请求DOM异常。也许你的库在IE9上失败了?

Google search on pkf_util returns ... this question, so we cannot rule out a bug in pkf_util.

谷歌搜索pkf_util返回…这个问题,我们不能排除pkf_util中的错误。