DOM compliance of IE 5.5

  • Thread starter Christopher Benson-Manica
  • Start date
C

Christopher Benson-Manica

I've been looking around for information on how well IE 5.5 handles
DOM script, but haven't found anything conclusive. I'm using script
to add rows to an existing table with code something like the
following:

function click() { alert(this.checked); }
var rowcount=1;
var tr, td, elem, colcount;
var table=document.getElementById( "theTable" );
var check_node=document.createElement( 'input' );
check_node.type='checkbox';
for( var idx=0; idx < 5; idx++ ) {
colcount=0;
tr=table.insertRow( rowcount++ );
td=tr.insertCell( colcount++ );
elem=td.appendChild( check_node.cloneNode(false) );
elem.checked=true;
elem.idx=idx;
elem.onclick=click;
td.appendChild( document.createTextNode('foo'+idx) );
}

Is this safe and advisable for IE 5.5/NS6 and higher?
 
M

Martin Honnen

Christopher said:
I'm using script
to add rows to an existing table with code something like the
following:

function click() { alert(this.checked); }
var rowcount=1;
var tr, td, elem, colcount;
var table=document.getElementById( "theTable" );
var check_node=document.createElement( 'input' );
check_node.type='checkbox';
for( var idx=0; idx < 5; idx++ ) {
colcount=0;
tr=table.insertRow( rowcount++ );

If you want to add to the table then it seems safer to do
rowcount = table.rows.length
and then call
table.insertRow(rowcount)
td=tr.insertCell( colcount++ );
elem=td.appendChild( check_node.cloneNode(false) );
elem.checked=true;

I would do
elem.checked = element.defaultChecked = true;
here, that usually increases your chances with various browsers to have
the dynamically created and inserted checkbox in the intended state.

Besides that it seems okay, docs for IE are here by the way:
<http://msdn.microsoft.com/library/d.../author/dhtml/reference/methods/insertrow.asp>
 

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
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top