本文介绍了究竟是什么导致了“HIERARCHY_REQUEST_ERR:DOM例外3”-Error?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它与jQuery的确切关系如何?我知道库在内部使用原生的javascript函数,但是只要出现这样的问题,它究竟在尝试做什么?

How exactly does it relate to jQuery? I know the library uses native javascript functions internally, but what exactly is it trying to do whenever such a problem appears?

推荐答案

它意味着你已经尝试将DOM节点插入DOM树中不能去的地方。我在Safari上看到的最常见的地方是不允许以下内容:

It means you've tried to insert a DOM node into a place in the DOM tree where it cannot go. The most common place I see this is on Safari which doesn't allow the following:

document.appendChild(document.createElement('div'));

一般来说,这只是一个错误,实际上是这样的:

Generally, this is just a mistake where this was actually intended:

document.body.appendChild(document.createElement('div'));

在野外看到的其他原因(摘自评论):

Other causes seen in the wild (summarized from comments):


  • 您正在尝试将节点附加到自身

  • 您试图将null附加到节点

  • 您正在尝试将节点附加到文本节点。

  • 您的HTML无效(例如,无法关闭目标节点)

  • 浏览器认为您尝试附加的HTML是XML(通过向注入的HTML添加<!doctype html> 进行修复,或者在通过XHR获取时指定内容类型)

  • You are attempting to append a node to itself
  • You are attempting to append null to a node
  • You are attempting to append a node to a text node.
  • Your HTML is invalid (e.g. failing to close your target node)
  • The browser thinks the HTML you are attempting to append is XML (fix by adding <!doctype html> to your injected HTML, or specifying the content type when fetching via XHR)

这篇关于究竟是什么导致了“HIERARCHY_REQUEST_ERR:DOM例外3”-Error?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 01:52