解决在IE tbody中使用innerHTML报运行时错误问题

来源:互联网 发布:淘宝转运服务 编辑:程序博客网 时间:2024/05/22 03:37
解决在IE下tbody中使用innerHTML报运行时错误问题,使用innerHTML赋值时,用下面的MSIEsetTBodyInnerHTML函数进行赋值.
// this function must come before calling it to properly set “temp” //fix MS Internet Exploder’s lamenessfunction MSIEsetTBodyInnerHTML(tbody, html) {   var temp = MSIEsetTBodyInnerHTML.temp;  temp.innerHTML = '<table><tbody>' + html + '</tbody></table>';  tbody.parentNode.replaceChild(temp.firstChild.firstChild, tbody); }MSIEsetTBodyInnerHTML.temp = document.createElement('div');if (navigator  &&  navigator.userAgent.match( /MSIE/i ))    MSIEsetTBodyInnerHTML(tbody, html);else  //by specs, you can not use “innerHTML” until after the page is fully loaded    tbody.innerHTML=html;  


0 0
原创粉丝点击