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

标签 javascript internet-explorer internet-explorer-6 prototypejs

我在 XP 上使用 IE 6(企业强制版本),以及(主要)Firefox 3。在这些中,我使用 prototype.js 库版本 1.6.0.3 制作 DHTML 表。

我有事件处理程序 javascript 代码来向表中添加一行,这在 Firefox 下工作正常,但在 Internet Explorer 下完全被忽略。我可以遍历 MS“脚本调试器”中的代码(是的,我知道它已经过时且已弃用,但它可用),所以我知道该事件正在被 Hook 。

代码是这样的形式:

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 中,而不是直接插入到 TABLE 中。否则 IE 不会显示/插入/不管它。

关于javascript - prototype.js - Element.insert( Element) 在 IE 6 下被忽略?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/941845/

相关文章:

javascript - 带有对象的闭包

javascript - JQuery:将新单元格附加到表格并循环遍历它们在 FF、Chrome 中有效,但在 IE 中无效

css - IE8 和 Primefaces p :selectOneMenu misbehave when having a lots of p:selectOneMenu in a form

css - IE 6 和 FireFox 3.6 中的文本框大小不同

javascript - 跨窗口传递回调函数导致 ie 出错

javascript - 使用不显眼的 javascript 对元素列表进行 Ajax 请求

javascript - 如何使用 jQuery/JavaScript 对 svg 路径进行动画处理?

javascript - 在 DOM 中注入(inject)脚本

java - Spring Framework MVC 中的 "Webpage has expired"

html - 如何在 IE6 中修复导航