471,624 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,624 software developers and data experts.

Table appendChild/removeChild crashes IE6

Hi All,

I'm creating a table using createElement / appendChild and everything
works great.
Ussualy I have no more than 20 rows and they contain less that 5
columns.

Where my code starts to break (IE6 only, FF works great) is when I
quickly clear(removeChild) the table and insert new rows. My problem is
that I am getting a IE6 crash and the last log message shows a
different location most of the time.

Trying to use deleteRow, insertRow is no different and my understanding
is that innerHTML is readonly with TOM.

So what can I do? Any ideas?

Regards,
Sebastian

Jul 13 '06 #1
3 9781
sf****@gmail.com wrote:
Hi All,

I'm creating a table using createElement / appendChild and everything
works great.
Ussualy I have no more than 20 rows and they contain less that 5
columns.

Where my code starts to break (IE6 only, FF works great) is when I
quickly clear(removeChild) the table and insert new rows. My problem is
that I am getting a IE6 crash and the last log message shows a
different location most of the time.

Trying to use deleteRow, insertRow is no different and my understanding
is that innerHTML is readonly with TOM.

So what can I do? Any ideas?

Regards,
Sebastian

Are you taking into account the implicit TBODY element?

HTML pages served as HTML always have an implicit TBODY element.
XHTML pages served as XHTML do not.
XHTML pages served as HTML may or may not.

Step carefully :-)

Jeremy
Jul 13 '06 #2

sf****@gmail.com wrote:
Hi All,

I'm creating a table using createElement / appendChild and everything
works great.
Ussualy I have no more than 20 rows and they contain less that 5
columns.

Where my code starts to break (IE6 only, FF works great) is when I
quickly clear(removeChild) the table and insert new rows. My problem is
that I am getting a IE6 crash and the last log message shows a
different location most of the time.

Trying to use deleteRow, insertRow is no different and my understanding
is that innerHTML is readonly with TOM.

So what can I do? Any ideas?
Difficult to tell without code. In IE, when using
createElement/appendChild for table rows, you must add the rows to a
table section element (tbody, thead, tfoot). Other browsers allow you
to append created rows to the table and then add them to the tbody.

If you have a reference to an existing row, you can do something like:

var oTR = document.createElement('tr');
rowRef.parentNode.appendChild(oTR);

insertRow is normally pretty reliable since it is DOM 1, remember to
include an index value for where to put the row (IE allows you to omit
it):

var oTR = tableRef.insertRow(-1);
'-1' will insert the row as the last in the table. The tableSection
interface supports insertRow too, so you can get a reference to a table
section element and use insertRow with that:

var oTR = tBodyRef.insertRow(-1);
The index must be in the range -1 to tBodyRef.rows.length. I've
created thousands of rows using insertRow in IE and never had any
problem with it.
--
Rob

Jul 13 '06 #3
Thanks for your responses Rob & Jeremy.

As I was trying to get a cleaner version of the
code(http://webfx.eae.net/dhtml/collist/columnlist.html) that I could
post I found the bug:

....
this._eBodyCols = this._eBodyTable.tBodies[0].rows[0].cells;
....

and then when remove row would remove the first row I'll be left with a
dangling reference.

The crash was happening when accessing the non-null
this._eBodyCols.length

So indeed, the bug was not in the TOM ;) but it's a crash nonetheless..

Regards,
Sebastian

Jul 19 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Steve S | last post: by
2 posts views Thread by Joakim Braun | last post: by
2 posts views Thread by Mike | last post: by
4 posts views Thread by SirCodesALot | last post: by
10 posts views Thread by r_ahimsa_m | last post: by
5 posts views Thread by jrod11 | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.