小白教程
所有教程
关于
Search
172.70.131.52
172.70.131.52
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Met document importnode”的源代码
本页内容
上一节:
Prop_document_implementation
下一节:
Prop_document_inputencoding
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:document.importNode()}}[[Category:dom obj document|27]] = HTML DOM importNode() 方法 = [[dom obj document|Document 对象]] 返回iframe中第一个 H1 元素: <sample title="" desc="" lang="html" hererun="1"> var frame=document.getElementsByTagName("iframe")[0] var h=frame.contentWindow.document.getElementsByTagName("h1")[0]; var x=document.importNode(h,true); </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <button onclick="myFunction()">点我</button> <p id="demo">点击上面的按钮以获取和显示在iframe第一个H1元素的值:</p> <script> function myFunction(){ var frame=document.getElementsByTagName("iframe")[0] var h=frame.contentWindow.document.getElementsByTagName("h1")[0]; var x=document.importNode(h,true); document.getElementById("demo").appendChild(x); }; </script> <iframe src="http://www.w3cschool.cc" style="height:280px;width:420px;"></iframe> <p><strong>Note:</strong> IE 8 及更早的版本不支持importNote方法</p> </body> </html> </run> == 定义和用法 == importNode() 方法把一个节点从另一个文档复制到该文档以便应用。 imported 节点可以试试任何节点类型。 如果 第二个值设置为 true,那么还要复制该节点的所有子孙节点。 == 浏览器支持 == 所有主要浏览器都支持 importNode() 方法 '''注意:''' Internet explorer 8 及 IE 更早版本不支持该方法。 == 语法 == <pre> document.importNode(node,deep)</pre> == 参数 == {| class="table table-striped table-hover" ! 参数 ! 类型 ! 描述 |- | deep | Boolean | 必须。如果为 true,还要递归复制 importedNode 节点的所有子孙节点。 |} == 返回值 == {| class="table table-striped table-hover" ! 类型 ! 描述 |- | Node object | The imported node |} == 技术细节 == {| class="table table-striped table-hover" | DOM 版本 | Core Level 2 Document Object |} [[dom obj document|Document 对象]]
返回至“
Met document importnode
”。
上一节:
Prop_document_implementation
下一节:
Prop_document_inputencoding