[JavaScript][IE] <tbody>.innerHTML
bamccaig

Does anybody know why IE errors (Unknown runtime error) when trying to set or append to the innerHTML property of a <tbody> DOM object. Is it possible to do or will I just have to stop using <thead>, <tbody>, and <tfoot> tags? :'( (I know innerHTML is a hack, but it's fast and easy and I've been instructed to use it :'().

Matthew Leverton

IE doesn't support it. Every other browser does.

Jonny Cook

innerHTML is a hack? That's the first I've heard of that. In fact, I've heard that it's better than manually manipulating the DOM because the DOM methods are slow. Although I usually just use the DOM methods because they are fun. :D

bamccaig
Jonny Cook said:

innerHTML is a hack? That's the first I've heard of that. In fact, I've heard that it's better than manually manipulating the DOM because the DOM methods are slow. Although I usually just use the DOM methods because they are fun. :D

There is no standard for it that I'm aware of. It is a proprietary extension implemented in IE that was adopted by other browsers for compatibility.

Matthew Leverton

Note that you could do something like:

var html = "<table><thead> ... </thead></table>";
var div = (some hidden div);
div.innerHTML = html;

var thead = (the thead I wanted to change);
thead.parentNode.replaceChild(div.table.thead, thead);

It contains much pseudocode obviously.

But I would just let IE fail a miserable death.

bamccaig

Screw it... I already had this code working with DOM and I'm not about to hack it up to work with innerHTML... Thanks for the fast response.

Jonny Cook
Quote:

There is no standard for it that I'm aware of. It is a proprietary extension implemented in IE that was adopted by other browsers for compatibility.

Hmm... yeah I heard that too. I guess that makes it a hack. Well, until IE incudes textContent I don't really have any choice but to use it...

Quote:

But I would just let IE fail a miserable death.

I'm all for that... but it's probably not the smartest thing to shut out 90% percent of your audience. Well, now it's probably more like 60%.

Thread #597238. Printed from Allegro.cc