[thelist] innerHTML on a table (Was: AJAX Tip)

Christian Heilmann codepo8 at gmail.com
Thu Apr 6 12:59:17 CDT 2006


> In case someone reading the above thought of doing some innerHTML in
> tables:
>
> Setting the innerHTML of tables (and table rows and some other table
> sub-elements) is NOT supported in Internet Explorer. Setting the
> innerHTML on table rows works in Firefox (didn't try on a table), but in
> IE, you have to walk through each cell (TD or TH) and set their
> innerHTML separately.

that makes the DOM approach easier. What about creating the table as
an XML string on the backend and just include it in a document via
innerHTML?

> Not as handy, perhaps, but I suppose it guarantees that the number of
> rows and columns are consistent after a change. Merged cells (colspan>1,
> rowspan>1) might be a problem, too. Anyway, I had hoped to replace table
> rows, updated via XHR (great new? acronym...),

Nah, XHR has been around for ages, I like it (excerpt from the chapter
8 of my book, finished minutes ago:

Let's go for a simpler example at first. The demo file exampleXHR.html
uses AJAX (well, without the X as there is no XML involved) to load
and display files from the server when the user clicks a link as shown
in Figure 8-2:
Insert 6803f0802.tiff
Figure 8-2 Loading external files via AJAX
The magic wand behind all of this is an object called XMLHttpRequest
or short XHR. This is a non-standard object insofar it has no mention
on the W3C site but it is supported across all modern browsers
(Safari, Mozilla/Firefox, Opera). MSIE does not support XHR, but uses
an ActiveX object instead. The good news is that it works the same
way.

Oops, I have to ammend the W3C comment now :-)
--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/



More information about the thelist mailing list