Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

javascript - 究竟是什么导致“HIERARCHY_REQUEST_ERR:DOM异常3” - 错误?(What exactly can cause an “HIERARCHY_REQUEST_ERR: DOM Exception 3”-Error?)

How exactly does it relate to jQuery?(它与jQuery有何关系?)

I know the library uses native javascript functions internally, but what exactly is it trying to do whenever such a problem appears?(我知道该库在内部使用本机javascript函数,但是只要出现这样的问题,它究竟在尝试做什么?)   ask by Julian Weimer translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It means you've tried to insert a DOM node into a place in the DOM tree where it cannot go.(这意味着您已尝试将DOM节点插入到DOM树中无法访问的位置。)

The most common place I see this is on Safari which doesn't allow the following:(我看到的最常见的地方是Safari,它不允许以下内容:)
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):(在野外看到的其他原因(从评论中总结):)

  • You are attempting to append a node to itself(您正在尝试将节点附加到自身)
  • You are attempting to append null to a node(您正在尝试将null附加到节点)
  • You are attempting to append a node to a text node.(您正在尝试将节点附加到文本节点。)
  • Your HTML is invalid (eg failing to close your target node)(您的HTML无效(例如,无法关闭目标节点))
  • 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)(浏览器认为您尝试附加的HTML是XML(通过向注入的HTML添加<!doctype html>或通过XHR获取时指定内容类型来修复))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...