Gaurav
Gaurav

Reputation: 8487

Inserting content into iframe javascript

How can we insert the content of 1 iframe into another. Is this possible?

Upvotes: 0

Views: 79

Answers (1)

balkon_smoke
balkon_smoke

Reputation: 1206

if I understood your question correctly. Something like this. But you should optimize this part of code before use it.

var oIFrame1 = document.getElementById("myframe1"),
    oIFrame2 = document.getElementById("myframe2");
var oDoc1 = (oIFrame1.contentWindow || oIFrame1.contentDocument);
if (oDoc1.document) oDoc1 = oDoc1.document;
var oDoc2 = (oIFrame2.contentWindow || oIFrame2.contentDocument);
if (oDoc2.document) oDoc2 = oDoc2.document;
oDoc1.body.innerHTML = oDoc2.body.innerHTML;

Upvotes: 1

Related Questions