has an undiagnosed addiction to steamed pork buns
and works on webby stuff at Mozilla. more »

More like tstupid

I spent a half hour trying to figure out why my site was rendering perfectly in Firefox, but not at all in IE7. I went through the trouble of finding the Microsoft Script Debugger (did I mention Firefox comes with a Javascript/CSS Debugger?) to find that it wasn’t a JavaScript error. I resorted to the Google, which led me to my solution. I vaguely remember encountering this problem a few years ago as well, but apparently didn’t learn my lesson.

You can’t add tr’s to a table in IE. You have to add it to a tbody. ERGO, this does not work:

var table = document.createElement('table');
var tr = document.createElement('tr');
var td = document.createElement('td');
td.innerHTML = 'IE sucks';
tr.appendChild(td);
table.appendChild(tr);

You must do this instead:

var table = document.createElement('table');
var tbody = document.createElement('tbody');
var tr = document.createElement('tr');
var td = document.createElement('td');
td.innerHTML = 'IE sucks';
tr.appendChild(td);
tbody.appendChild(tr);
table.appendChild(tbody);

Indeed.

(this post is no longer accepting new comments)