M
markszlazak
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:lightyellow;
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:relative;
background-color:lightgrey;
border-width:1px;
border-color:black;
border-style:solid;
margin:0px;
padding:0px;
visibility:visible;
top:0;
left:10;
height:13;
width:28;
text-align:center;
font-size:10;
font-family:sans-serif;'
</tr>
<tr class='gridRow'>
<td class='gridCell'></td>
</tr>
</table>
<script>
var grid = document.getElementById('grid1'),
cells = grid.getElementsByTagName('td');
var divStyle = 'position:relative; ' +
'background-color:lightgrey; ' +
'border-width:1px; ' +
'border-color:black; ' +
'border-style:solid; ' +
'margin:0px; ' +
'padding:0px; ' +
'visibility:visible; ' +
'top:0; ' +
'left:10; ' +
'height:13; ' +
'width:28; ' +
'text-align:center; ' +
'font-size:10; ' +
'font-family:sans-serif;';
function addCellDIV(el) {
var d = document.createElement('div');
d.setAttribute('style', divStyle);
d.appendChild(document.createTextNode('DIV'));
el.appendChild(d);
}
addCellDIV(cells[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:lightyellow;
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:relative;
background-color:lightgrey;
border-width:1px;
border-color:black;
border-style:solid;
margin:0px;
padding:0px;
visibility:visible;
top:0;
left:10;
height:13;
width:28;
text-align:center;
font-size:10;
font-family:sans-serif;'
</td>DIV</div>
</tr>
<tr class='gridRow'>
<td class='gridCell'></td>
</tr>
</table>
<script>
var grid = document.getElementById('grid1'),
cells = grid.getElementsByTagName('td');
var divStyle = 'position:relative; ' +
'background-color:lightgrey; ' +
'border-width:1px; ' +
'border-color:black; ' +
'border-style:solid; ' +
'margin:0px; ' +
'padding:0px; ' +
'visibility:visible; ' +
'top:0; ' +
'left:10; ' +
'height:13; ' +
'width:28; ' +
'text-align:center; ' +
'font-size:10; ' +
'font-family:sans-serif;';
function addCellDIV(el) {
var d = document.createElement('div');
d.setAttribute('style', divStyle);
d.appendChild(document.createTextNode('DIV'));
el.appendChild(d);
}
addCellDIV(cells[1]);
</script>
</body>
</html>