Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Popup - Append a Table obtained from the parent window

Status
Not open for further replies.

Lighther

Programmer
Oct 4, 2009
8
CL
Hi everyone, I'm having problem getting this work in IE, the code works fine in Firefox.

The problem:

I'm opening a child window which goes to the parent window to get 2 tables, then I clone them and need to be appended to 2 divs in the child window.

The popup is being opening fine.

I'm already getting the 2 objects in the child window, but it seems the appendChild function isn't appending the elements into the divs.

Here is the code:

window.onload = function(){
// First Div
var divTitle = document.getElementById("tablaTitle");
// Second Div
var divTabla = document.getElementById("tabla");

//First table obtained from the parent window
var title = window.opener.document.getElementById("titleDataTable");

//Second table obtained from the parent window
var datatable = window.opener.document.getElementById(window.opener.document.getElementById("edsUnit").value);

//I'm declaring new var for both tables cloned...
var newTitle = title.cloneNode(true);
var newDT = datatable.cloneNode(true);

//...then I change their ids (This is working fine)
newTitle.id = 'popupTitle';
newDT.id = 'popuptable';

//Finally I append the tables into the divs (Maybe this needs more things to be defined in IE, but it works perfect in Firefox.
divTitle.appendChild(newTitle);
divTabla.appendChild(newDT);
}

Thx for any help!!!!!
Juan Pablo
 
Hi

Older Explorers had problems with [tt]cloneNode()[/tt] when deep-cloning certain element types.

But as we know nothing about the HTML an which you code operates, nobody can say anything for sure.

Feherke.
 
Hi feherke. I have not problems with the cloneNode function, I have tested the script and I know that the error is in the appendChild function. Maybe I have to do something else to append a table element into a div. As I said, the elements appended in the last lines are tables, with a caption, th and td elements defined.

thx for your answer!!!!
 
Hi

If you are creating the rows and cells with [tt]document.createElement()[/tt] and adding them to the [tt]table[/tt] with [tt]appendChild[/tt], see thread216-1568392 .

Feherke.
 
No, I'm not creating the table with document functions, the table is written completly in html, obtained by php code.

I'll make some additional tests.
 
Well, I have added a try statement and I get an error that refers to the interface used to clone and append the elements. I got the uncompatible interface, err.description.

I'll continue testing this. If anyone knows another way or a specific declaration of varaibles to get elements from a parent window, when a pop up is created, post it here please.

Thx!!!!
 
Try creating a tbody to place the <th> in and see if it works.
 
I have done some tests and I can say that cloneNode and appendChild are working propperly, the problem is generated by the object gotten by "window.opener.document.getElementById". I think this object is a html table object but with something additional that makes the appendChild fail.

If anyone knows about this or have any posible idea, please fell free to post!!!

Thx a loot!!!!
 
Up!!!!

Sorry, I haven't found a solution for my problem, please, read again, I need help with this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top