<script> <br>var oTable=document.getElementById("test"); <br>oTable.innerHTML="<tr><td> innerHTML</ td></tr>"; <br></script>
IE9:Invalid target element for this operation.
So we can only use other solutions. My solution:
var oTable=document.getElementById("test");
//oTable.innerHTML="
< ;td>innerHTML
";
setTableInnerHTML(oTable,"
innerHTML |
");
function setTableInnerHTML(table, html) {
if(navigator && navigator.userAgent.match(/msie/i)){
var temp = table.ownerDocument.createElement('div');
temp. innerHTML = '
';
if(table.tBodies.length == 0){
var tbody=document.createElement ("tbody");
table.appendChild(tbody);
}
table.replaceChild(temp.firstChild.firstChild, table.tBodies[0]);
} else {
table.innerHTML=html;
}
}
Here we only deal with the table. A similar solution can be used for other unsupported elements.
In addition, tables in IE10 already support innerHTML.