document.adoptNode & document.importNode & node.ownerDocument All In One
2022/7/6 14:22:12
本文主要是介绍document.adoptNode & document.importNode & node.ownerDocument All In One,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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, 禁止转载
这篇关于document.adoptNode & document.importNode & node.ownerDocument All In One的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-15PingCAP 黄东旭参与 CCF 秀湖会议,共探开源教育未来
- 2024-05-13PingCAP 戴涛:构建面向未来的金融核心系统
- 2024-05-09flutter3.x_macos桌面os实战
- 2024-05-09Rust中的并发性:Sync 和 Send Traits
- 2024-05-08使用Ollama和OpenWebUI在CPU上玩转Meta Llama3-8B
- 2024-05-08完工标准(DoD)与验收条件(AC)究竟有什么不同?
- 2024-05-084万 star 的 NocoDB 在 sealos 上一键起,轻松把数据库编程智能表格
- 2024-05-08Mac 版Stable Diffusion WebUI的安装
- 2024-05-08解锁CodeGeeX智能问答中3项独有的隐藏技能
- 2024-05-08RAG算法优化+新增代码仓库支持,CodeGeeX的@repo功能效果提升