标签:node ownerDocument adoptNode en https document importNode
document.adoptNode & document.importNode & node.ownerDocument All In One
将外部文档
的节点
插入当前文档
之前,你必须使用 document.importNode()
从外部文档导入源节点
,或者使用 document.adoptNode()
导入源节点
document.adoptNode
https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptNode
document.importNode
importNode(externalNode)
importNode(externalNode, deep)
https://developer.mozilla.org/en-US/docs/Web/API/Document/importNode
node.ownerDocument
如果在本身是文档的节点上使用此属性,则值为 null
// Given a node "div", get the top-level HTML child of the document object
const div = document.querySelector('div');
const documentRoot = div.ownerDocument;
// #document
const html = documentRoot.documentElement;
// <html>...</html>
// document self object ❓iframe
const dom = document.querySelector('html');
const documentRoot = dom.ownerDocument;
// <html>...</html> ✅
// null ❌
// document self object
document;
// #document
document.ownerDocument;
// null ✅
https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument
https://developer.mozilla.org/en-US/docs/Web/API/Node
https://developer.mozilla.org/en-US/docs/DOM/document
refs
https://github.com/mdn/content/pull/18005
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载
标签:node,ownerDocument,adoptNode,en,https,document,importNode 来源: https://www.cnblogs.com/xgqfrms/p/16449386.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。