469,271 Members | 1,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Works in Firefox, not in IE (basic DOM scripting)

The following results in a second row, with a cell containing 'xxx',
being added to the table on the web page, but only in Firefox, not in
IE 6. In IE 6, the JavaScript function runs - in fact, the 2 alerts pop
up and the border of the table is set to 1. But, the second row is not
added to the table. Any ideas?
<html>
<head>
<title>Results of JavaScript Test</title>
<script type="text/javascript">
function testJavaScript() {
try {
var table = document.getElementById('mytable');
alert("adding border");
table.setAttribute('border','1');
var txt = document.createTextNode('xxx');
var th = document.createElement('th');
th.appendChild(txt);
var tr = document.createElement('tr');
tr.appendChild(th);
table.appendChild(tr);
alert('done');

}
catch (err) {
alert("ERROR: " + err);
}
}
</script>
</head>
<body id="htmlbody" onload="testJavaScript();">
<table id="mytable" border="0" frame="box">
<tr><th>aaa</th></tr>
</table>
</body>
</html>

Oct 6 '06 #1
1 1246


On Oct 6, 6:19 pm, "jdeig...@pcgus.com" <jdeig...@pcgus.comwrote:
table.appendChild(tr);
table.tBodies[0].appendChild(tr);

Oct 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by LAshooter | last post: by
11 posts views Thread by Krij | last post: by
9 posts views Thread by johnd126 | last post: by
2 posts views Thread by Altman | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.