[Javascript] Works in Firefox, not in IE 6
M
lists at gazelasport.sk
Mon Oct 9 06:05:45 CDT 2006
IE creates anonymous <tbody> element, so you need to add rows to this
one. You can simply create your table like this:
<table>
<tbody id="mytable">
<!-- ... rows here -->
</tbody>
</table>
This will work both in FF and IE.
John Deighan wrote:
> 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>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list