Firefix works fine but I'm having a problem inserting a DIV into a
HTML table cell dynamically with IE 6. The following code has a two
cell table with one DIV hard-coded into the first (top) cell and a
second DIV put in via Javascript. The second DIV shows up like the
first in Firefox. However, in IE 6, only the text within the second
DIV shows but the DIV's style and positioning are lost. What is the
problem?
<html>
<head>
<style>
.grid {
}
.gridRow {
height:30;
}
.gridCell {
background-color:lightyell ow;
width:50;
}
</style>
</head>
<body>
<table id='grid1' class='grid' border='1' cellpadding='0'
cellspacing='0' >
<tr class='gridRow' >
<td class='gridCell '>
<div
style= 'position:relat ive;
background-color:lightgrey ;
border-width:1px;
border-color:black;
border-style:solid;
margin:0px;
padding:0px;
visibility:visi ble;
top:0;
left:10;
height:13;
width:28;
text-align:center;
font-size:10;
font-family:sans-serif;'
</td>
</tr>
<tr class='gridRow' >
<td class='gridCell '></td>
</tr>
</table>
<script>
var grid = document.getEle mentById('grid1 '),
cells = grid.getElement sByTagName('td' );
var divStyle = 'position:relat ive; ' +
'background-color:lightgrey ; ' +
'border-width:1px; ' +
'border-color:black; ' +
'border-style:solid; ' +
'margin:0px; ' +
'padding:0px; ' +
'visibility:vis ible; ' +
'top:0; ' +
'left:10; ' +
'height:13; ' +
'width:28; ' +
'text-align:center; ' +
'font-size:10; ' +
'font-family:sans-serif;';
function addCellDIV(el) {
var d = document.create Element('div');
d.setAttribute( 'style', divStyle);
d.appendChild(d ocument.createT extNode('DIV')) ;
el.appendChild( d);
}
addCellDIV(cell s[1]);
</script>
</body>
</html>
HTML table cell dynamically with IE 6. The following code has a two
cell table with one DIV hard-coded into the first (top) cell and a
second DIV put in via Javascript. The second DIV shows up like the
first in Firefox. However, in IE 6, only the text within the second
DIV shows but the DIV's style and positioning are lost. What is the
problem?
<html>
<head>
<style>
.grid {
}
.gridRow {
height:30;
}
.gridCell {
background-color:lightyell ow;
width:50;
}
</style>
</head>
<body>
<table id='grid1' class='grid' border='1' cellpadding='0'
cellspacing='0' >
<tr class='gridRow' >
<td class='gridCell '>
<div
style= 'position:relat ive;
background-color:lightgrey ;
border-width:1px;
border-color:black;
border-style:solid;
margin:0px;
padding:0px;
visibility:visi ble;
top:0;
left:10;
height:13;
width:28;
text-align:center;
font-size:10;
font-family:sans-serif;'
>DIV</div>
</tr>
<tr class='gridRow' >
<td class='gridCell '></td>
</tr>
</table>
<script>
var grid = document.getEle mentById('grid1 '),
cells = grid.getElement sByTagName('td' );
var divStyle = 'position:relat ive; ' +
'background-color:lightgrey ; ' +
'border-width:1px; ' +
'border-color:black; ' +
'border-style:solid; ' +
'margin:0px; ' +
'padding:0px; ' +
'visibility:vis ible; ' +
'top:0; ' +
'left:10; ' +
'height:13; ' +
'width:28; ' +
'text-align:center; ' +
'font-size:10; ' +
'font-family:sans-serif;';
function addCellDIV(el) {
var d = document.create Element('div');
d.setAttribute( 'style', divStyle);
d.appendChild(d ocument.createT extNode('DIV')) ;
el.appendChild( d);
}
addCellDIV(cell s[1]);
</script>
</body>
</html>
Comment