I tried to create an HTML page that used ECMAScript to generate a calendar. First, I used document.write() to create it -- that worked in IE, Mozilla, and Firebird. Then, I tried to use DOM methods. This is much nastier. First, I discovered that IE will not display a table that is created using raw createElement() calls for TR, TD, and TH elements. The debugger reveals that the correct object model has been created, but IE just refuses to display it. I then switched to use the insertRow() and insertCell() methods on the various table objects. This mostly worked in the browsers, but:
- Moz/FB put all rows into the THEAD instead of just the header rows.
- None of the browsers created TH elements in the THEAD section -- they all used TDs.
- IE insisted upon wrapping the text contained in the header at the first space -- whether it needed to wrap or not.
After much fidgeting, I just could not get the bugs to disappear. I guess that it is best to use good old document.write()... but that means that one needs to do HTML escaping.
Update: I found a workable compromise. First, I didn't bother with the THEAD element at all since Moz got it wrong. Second, I used createElement("th") to create the header cells. IE doesn't seem to choke on that. The result is in calendar.html.