Iulian Ilea wrote:
Hello,
I try to create a calendar. It's done, it's works fin in Firefox, but
it's not displayed in Internet Explorer.
Structure:
createElement("div"); append.document.body
createElement("table"); append. the div above
createElement("tr"); append to table
createElement("td"); append to tr
I try to debug this problem and I figure out that if I give a dimension
to div (height and width) it will apear on the page. Any ideas?
When using createElement/appendChild for table rows, IE wants you to
add them to a tbody element, not directly to the table element. So you
can either create a tbody, append it to the table, then append rows to
that, or you can create a table and use the insertRow() method[1]:
var numRows = 6;
var numCells = 7;
var table = document.createElement('table');
var row, cell;
for (var i=0; i<numRows; i++){
row = table.insertRow(-1);
for (var j=0; j<numCells; j++){
cell = row.insertCell(-1);
cell.innerHTML = 'Row ' + i + ' cell ' + j;
}
}
document.body.appendChild(table);
Ensure you use appropriate feature detection.
1. <URL:
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-39872903 >
--
Rob