4번독수리의 둥지

IE has a problem replacing TBODY contents with innerHTML. 본문

Javascript

IE has a problem replacing TBODY contents with innerHTML.

4번독수리 2014. 10. 23. 17:05

IE has a problem replacing TBODY contents with innerHTML. The jQuery given above works; if you are not using jQuery, another solution is to have a <div id='helper' style='visibility:hidden'/> somewhere in the page - when the response arrives, put the value with a surrounding <table> tag into the hidden div, then use the DOM to remove the old contents from your visible tag and insert the elements from the hidden tag 1 by 1:

var a=document.getElementById("dealdata");

while(a.firstChild!=null)
  a.removeChild(a.firstChild);

var b=document.getElementById("helper");
b.innerHTML="<table>"+this.responseText+"</table>";
while(b.tagName!="TR") {
  if(b.tagName==null)
    b=b.nextSibling;
  else
    b=b.firstChild;
}
for(;b!=null;b=b.nextSibling)
  a.appendChild(b);
http://stackoverflow.com/questions/7180072/script-600-error-invalid-target-element-for-this-operation
 
20150429

javascript DOM Table object의 insertRow(), TableRow object의 insertCell()를 활용하면 좋음