Su said:
I directly want to construct a table inside iFrame.
<snip>
function buildiframetable() {
//I used a form with text boxes for table parameters
var tdpad = +document.forms("form1").tdpad.value
var tdspace = +document.forms("form1").tdspace .value
var tborder = +document.forms("form1").tborder .value
var rows = +document.forms("form1").rows .value
var cols = +document.forms("form1").cols .value
//I think NN wants name and id the same so getElementById works
var d = document.getElementById("iframe1").contentWindow.document
//build table
var table = d.createElement('table');
table.border = tborder;
table.cellPadding = tdpad;
table.cellSpacing = tdspace;
var tbody = d.createElement('tbody');
for (var i=0; i<rows; i++) {
var row = d.createElement('tr');
for (var j=0; j<cols; j++) {
var cell = d.createElement('td');
cell.appendChild(d.createTextNode(i + ', ' + j));
row.appendChild(cell);
}
tbody.appendChild(row);
}
table.appendChild(tbody);
d.body.appendChild(table)
}
code modified from a comp.lang.javascript post by Martin Honnen 04/07/04