[Javascript] Works in Firefox, not in IE 6

John Deighan jdeighan at pcgus.com
Fri Oct 6 09:36:53 CDT 2006


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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20061006/720b2adf/attachment.htm>


More information about the Javascript mailing list