How to use DOM Object ImportNode in JavaScript
In this article I am going to explain about DOM object importNode() method in JavaScript.
JavaScript DOM Object ImportNode() Method
JavaScript importNode() method use for import the element from another document. Its can be import any types of element.
Syntax
document.importNode(Node,true)
|
Example // In this example when you will click on button then a message will be display.
<html>
<head>
<script type="text/javascript">
function myfun() {
var frame = document.getElementsByTagName("iframe")[0]
var ss = frame.contentWindow.document.getElementsByTagName("h1")[0];
var mm = document.importNode(ss, true);
document.getElementById("test").appendChild(mm);
};
</script>
</head>
<body>
<button onclick="myfun()">
click me</button>
<p id="test">
click button for import page</p>
<iframe src="HTMLPage2.htm" style="height: 280px; width: 420px;"></iframe>
</body>
</html>
|
Output
You may also want to read these related articles: here
Ask Your Question
Got a programming related question? You may want to post your question here