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

Discussion in 'Javascript' started by Dmitry Kulinich, Jun 15, 2007.

  1. 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.

    --
    Thank you,
    De Cool (ICQ:213679052),
    EPE
     
    Dmitry Kulinich, Jun 15, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dominic
    Replies:
    5
    Views:
    12,816
    Thomas 'PointedEars' Lahn
    Sep 11, 2004
  2. lordy

    To clone or not to clone..

    lordy, Jul 7, 2006, in forum: Java
    Replies:
    3
    Views:
    748
    lordy
    Jul 7, 2006
  3. Dominic
    Replies:
    5
    Views:
    580
    Thomas 'PointedEars' Lahn
    Sep 11, 2004
  4. Replies:
    1
    Views:
    258
  5. Alexander Higgins
    Replies:
    0
    Views:
    243
    Alexander Higgins
    Dec 16, 2006
Loading...

Share This Page