Javascript prototype.js-Element.insert(元素)在IE 6下被忽略?

Javascript prototype.js-Element.insert(元素)在IE 6下被忽略?,javascript,internet-explorer,internet-explorer-6,prototypejs,Javascript,Internet Explorer,Internet Explorer 6,Prototypejs,我在XP上使用IE6(公司授权版本),以及(主要)Firefox3。在这些示例中,我使用prototype.js库1.6.0.3版制作了一个DHTML表 我有事件处理程序javascript代码向表中添加一行,在Firefox下运行良好,但在InternetExplorer下完全被忽略。我可以在MS“script debugger”中浏览代码(是的,我知道它很旧,不推荐使用,但它是可用的),因此我知道事件正在被钩住 代码的形式如下: var xTable = $( 'x_list') // i

我在XP上使用IE6(公司授权版本),以及(主要)Firefox3。在这些示例中,我使用prototype.js库1.6.0.3版制作了一个DHTML表

我有事件处理程序javascript代码向表中添加一行,在Firefox下运行良好,但在InternetExplorer下完全被忽略。我可以在MS“script debugger”中浏览代码(是的,我知道它很旧,不推荐使用,但它是可用的),因此我知道事件正在被钩住

代码的形式如下:

var xTable = $( 'x_list')  // id of x...
var aRow = new Element( 'tr')
aRow.setAttribute( 'id', id)
. . .
var xEl = new Element( 'td')
. . .
aRow.insert( xEl)
. . .
// alert( aRow.inspect() )
// alert( xTable.inspect() )
debugger  // check insert() implementation under IE
xTable.insert( aRow)

是否有其他人遇到过Element.insert()和Explorer之间的冲突?

您必须将新的TR元素插入到TBODY中,而不是直接插入到表中。否则IE不会显示/插入/不管它是什么

尝试在正在使用的
中创建一个
元素,然后附加到该元素而不是


这是我要做的第一件事。我模模糊糊地记得,如果没有
元素,Javascript对表的操作会很奇怪。

slosd回答得很好,只是添加了一点:IE7中也需要TBODY,但IE8中不需要TBODY。

谢谢(两位同时回答者),添加嵌套标记效果很好。