On 6 Dec 2004 08:11:15 -0800, <t.********@signal.qinetiq.com> wrote:
[snip]
<table>
...some rows...
<div id=placeholder></div>
</table>
[snip]
Any ideas? work arounds? Is this a problem with the DOM or the
function innerHTML?
Neither. It's a problem with your mark-up: it's invalid. The contents of
certain elements are restricted to a specific subset. For example, lists
(OL/UL) may only contain items (LI), and SELECT elements may only contain
OPTION and OPTGROUP elements. The same is true for TABLEs.
The valid elements are defined in the DTD that you're using with your
document. For instance,
<URL:http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1>. Notice the
line
<!ELEMENT TABLE - -
(CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
The elements in brackets show what a TABLE may contain as its immediate
children. The comma separation means, "in this order". So, an optional
CAPTION (denoted by ?), followed by either zero or more COL elements, or
zero or more COLGROUP elements, followed by an optional THEAD, followed by
an optional TFOOT, followed by at least one TBODY.
If you managed to follow that, you're probably wondering: "Well, what
about TR? Can't I include them directly? Most people do." The answer to
that is yes. If you don't explictly add a TBODY element, the browser will
do it for you.
So what does that all mean? The TBODY element - usually used to group rows
- will probably suffice for your placeholder. Your existing HTML will
become
<table>
<tbody>
<!-- original set of rows -->
</tbody>
<tbody id="placeholder">
<!-- your placeholder -->
</tbody>
</table>
This type of thing is why this group constant recommends that HTML should
be validated (use <URL:http://validator.w3.org/>) before it is scripted.
Invalid HTML can lead to unexpected behaviour, just as you've found here.
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.