SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cloning Node from Parent to Child

    Hi again;

    Can this be done ?

    I have a table in the parent and I would like to clone node in popup ..

    Code:
    <script type='text/javascript'>
    function PrintOffer(Annonce){
    	var PPw=window.open('about:blank')
    	setTimeout(function(){ PPw.document.title="impression annonce"
    		var newTable=PPw.document.createElement('table')
    		var newTB =PPw.document.createElement('tbody');
    		newTB.appendChild(Annonce)
    		newTable.appendChild(newTB)
    
    		PPw.document.body.appendChild(newTable)
    },1000)
    }
    
    </script>
    function is triggered with cloneNode(true) of tr in argument ...
    But IE doesn't like it at all, and firefox does half the job as the table tags do seem to have any effect in popup

    looks like the createElements and cloneNode cannot cross the boundary of their own documents ?

  2. #2
    SitePoint Addict
    Join Date
    Apr 2001
    Location
    Devon, UK
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It sounds like you could have problems using that method.

    As a suggestion, rather than opening a window with "about:blank", use an HTML page that has already has a head, body and table elements ready to use. That will cut down on your JS code (and I'm not convinced that it would work - have you tried viewing the generated source using Web Developer Toolbar?)

    If appending the cloned row does not work, then I'd suggest that you recurse through all the child elements of that row, find their type, attributes, and values, then append them to the popup window's DOM.

  3. #3
    SitePoint Evangelist SpaceFrog's Avatar
    Join Date
    Jan 2005
    Location
    Outerspace
    Posts
    511
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    unfortunately it looks like the Nodes cannot be shifted from a page to another...
    I worked around it by copying the innrHTML


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •