How to keep IE from removing rows 'spontaneously' from a table?

F

F. Da Costa

Hi all,

I'm encountering some (for me) inexplicable IE behaviour re. the removal of
rows in a table. Exactly the same code works like a charm in Gecko browsers.

Here is the situation:
Frame set with two frames: jsLib & mainContent
*jsLib* contains global variables and a function (see below) that are
utilized during the session.
*mainContent* contains the pages the user looks at. They are
semi-dynamically created through the use of embedded js.
This js uses the global variables of the jsLib(-frame).

In the jsLib there is a variable called _statictable. It is responsible for
keeping track of the the 'state' of the table. I cannot do this in the
mainContent frame because the page get replaced by new (table modifying) pages.

The jsLib contains a function (see below) that modifies DOM elements that
are shown via the mainContent.

I have got the above structure working to satisfaction in Gecko.
Using IE5+ I can initialize _staticTable but as soon as I re-enter the
createTable for a second time (basically adding a new tbody) the
_staticTable does *not* contain any rows anymore and thus the whole
exercise becomes useless because I need to *add* the new tbody to *something*.

Gecko just keeps the variable _staticTable in place no worries but IE seems
to mess something up. I suppose the question is obvious.
What is the best way to keep track of (in memory) values in IE, to be used
and modified for the duration of the session?

TIA
Fermin DCG


var _staticTable;
var _tbodyRows;

/**
* This function is responsible for inserting a new tBody in an extisting
table.
* @param win = the window from where the function is called (mainContent)
* @param table = the ID of the table where th tbody needs to be inserted
*/
function createTbody(win, tBodyID) {
var windoc = win.document;
var myDiv = windoc.getElementById("doc");

// creates/ get an element of type TABLE
if (tBodyID=="" || !_staticTable) {
_staticTable = windoc.getElementById("treeTable");
return;
}
else {
var defaultTable = windoc.getElementById("treeTable");
myDiv.replaceChild(_staticTable, defaultTable);
}

// creates an element whose tag name is TBODY
var mytablebody = windoc.getElementById(tBodyID);
// creating all cells within the rows
for(var j=0, rLen=_tbodyRows.length; j<rLen; j++) {
// creates an element whose tag name is TR
var mycurrent_row=windoc.createElement("TR");

// start working on the columns
for(var i=0, cLen=_tbodyRows[0].length; i < cLen; i++) {
// creates an element whose tag name is TD
var mycurrent_cell=windoc.createElement("TD");
// creates a Text Node
var currenttext=windoc.createTextNode(_tbodyRows[j]);
// appends the Text Node we created into the cell TD
mycurrent_cell.appendChild(currenttext);
// appends the cell TD into the row TR
mycurrent_row.appendChild(mycurrent_cell);
}
// appends the row TR into TBODY
mytablebody.appendChild(mycurrent_row);
}
}
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top