question 4 JScript Universal Guru: iframe: clone node & contentWindow

D

Dmitry Kulinich

It is really simple, yet I can't resolved more than week. I've read everything in msdn and iframes and tried in many many ways. Sorry 4 such a long letter.
1 Need to clone <tr> with <iframe> that contains <form> and hidden <input>s:
commented doesn't works:
function cloneRow(tr)
//var frame = document.getElementById("1");
//1
//var tr2 = tr.cloneNode(false);
//tr2.insertAdjacentHTML('afterBegin', tr.innerHTML);//first <td> open tag are not copied
//2
//var tr2 = tr.cloneNode(false);
//tr2.innerHTML = tr.innerHTML; //first <td> open tag are not copied
//3
//var tr2 = tr.cloneNode(false);
//tr2.insertAdjacentElement('afterBegin', tr); //existing element deleted and inserted again
// 4 copy iframe content child-by-child with DOM and insertAdjacentElement
// a lot of code but doesn't inserted properly - existing element deleted and inserted again
//5
tr2=tr.cloneNode(true);
if (tr.outerHTML.indexOf('IFRAME') != -1){

var _length = tr2.getElementsByTagName("IFRAME").length;

for (var i = 0; i < _length; i++) {

tr2.getElementsByTagName("IFRAME").outerHTML = tr.getElementsByTagName("IFRAME").outerHTML;

}}

//....a lot of code there, cleaning values in new row , setting new ones

return tr2;
}

2 Need to access contentWindow.document of new row, but it doesnt exists!:
function VectorDrawing_CreateImageURL (value)

{

var bgColor = this.getInputElement().bgColor;

var fgColor = this.getInputElement().fgColor;

var width = this.getIFrame().width;

var height = this.getIFrame().height;

var frameDoc = this.getIFrame().contentWindow.document;//Unspecified error

frameDoc.body.innerHTML = this.getIFrame().innerHTML;//body is null or not an object

frameDoc.getElementsByName("value")[0].value = value;

frameDoc.getElementsByName("bgColor")[0].value = bgColor;

frameDoc.getElementsByName("fgColor")[0].value = fgColor;

frameDoc.getElementsByName("width")[0].value = width;

frameDoc.getElementsByName("height")[0].value = height;

frameDoc.getElementById("form"+this.getAttribute("elNo")).submit();

}

3 So, we need to copy (1) in such way that structure of iframe internal document must be saved or access (2) contentWindow.document in another way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top