调试IE8 Javascript替换innerHTML运行时错误 [英] Debugging IE8 Javascript Replace innerHTML Runtime Error
本文介绍了调试IE8 Javascript替换innerHTML运行时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
function DeleteData(ID)
{
var ctrlId=ID.id;
var divcontents=document.getElementById(ctrlId).innerHTML;
var tabid=ctrlId.replace(/div/,'tab');
var tabcontents=document.getElementById(tabid).innerHTML;
alert(document.getElementById(tabid).innerHTML);
document.getElementById(tabid).innerHTML="<TBody><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr></TBody>";
document.getElementById(ctrlId).innerHTML='';
}
我试图用空表替换表, / p>
I am trying to replace the Table with empty table but
document.getElementById(tabid).innerHTML="<TBody><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr></TBody>";
此行导致未知的运行时错误
/ p>
this line is causing Unknown Runtime Error
推荐答案
您无法为表的innerHTML设置值,您应该访问子单元格或行,并将其更改为: / p>
You can't set value to a table's innerHTML, you should access to child cells or rows and change them like that :
document.getElementById(tabid).rows[0].cells.innerHTML = 'blah blah';
有关详细信息/示例:表,TableHeader,TableRow,TableData对象
For more info/example : Table, TableHeader, TableRow, TableData Objects
这篇关于调试IE8 Javascript替换innerHTML运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文