elements displayed in FF but not in IE

I

Iulian Ilea

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?
 
A

ASM

Iulian Ilea a écrit :
I try to create a calendar. It's done, it's works fin in Firefox, but
it's not displayed in Internet Explorer.

Answer wasn't given ?
(to you or your fellow)
Structure:

why don't you give your real code ?
How to see where you're wrong ?
createElement("div"); append.document.body
createElement("table"); append. the div above

I prefer append the table when it is complete

create div

create table

create tbody <---- here what missing for IE

create tr

create td append td to tr
create td append td to tr

append tr to tbody
append tbody to table
append table to div
append div to document.body
 
R

RobG

Iulian said:
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-HTML/html.html#ID-39872903 >
 
R

Randy Webb

RobG said the following on 12/15/2006 7:21 PM:
When using createElement/appendChild for table rows, IE wants you to
add them to a tbody element, not directly to the table element.

IE along with the specs say add them to a tbody. It should be noted that
IE is correct with regards to this and that Opera/Mozilla/etc.. get it
dead wrong.

You see enough IE bashing so Moz/Opera should get it when they deserve it :)
 
I

Iulian Ilea

Randy said:
RobG said the following on 12/15/2006 7:21 PM:

IE along with the specs say add them to a tbody. It should be noted that
IE is correct with regards to this and that Opera/Mozilla/etc.. get it
dead wrong.

You see enough IE bashing so Moz/Opera should get it when they deserve it :)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

Thanks all, this was the problem. I was out of the city yesterday and I
had no connection to internet, that is way my answer is so delayed. I
have just started to work with DOM and I learn new things every day.

Thanks again,

Iulian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,436
Messages
2,571,696
Members
48,796
Latest member
Greg L.
Top