Click to See Complete Forum and Search --> : innerHTML trouble in IE


w_culver
05-21-2003, 04:44 AM
Hiya,
Im currently making a script to arrange data in a table and im having serious hastles!

I wonder if anyone can help if i post a lil of my script.
What it is, is that im trying to turn the body data of the table of, with a simple script. It works fine in gorgeous mozilla but nasty IE wont do it for some reason.

function tableControl (tabId) {
//Properties
this.tableId = tabId;
this.table = document.getElementById(this.tableId);
this.tablebody = this.table.getElementsByTagName("tbody").item(0);
this.tablerows = this.tablebody.rows.length;
this.rowdata = new Array();

this.tablebody.innerHTML = ""; <-This line doesn't work in IE :(

Gollum
05-21-2003, 05:00 AM
Not quite sure why it's happening - Interdev says "Unknown runtime error"

innerHTML isn't the most reliable way to do DHTML, one alternative is

instead of

oTBody.innerHTML = ""; // which fails in IE

use
while ( oTBody.hasChildNodes() ) oTBody.removeChild(oTBody.firstChild);

which uses the DOM level 1 methods

w_culver
05-21-2003, 05:10 AM
Thanks for that, i'll give that a go..

I managed to solve that innerHTML problem out anyway, turns out, that property is read-only for most tags in IE, which means i gotta re write a whole chunk of my script <rips hair out>

http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/innerhtml.asp