Internet Explorer throws SCRIPT5022: HierarchyRequestError when trying to appendChild an HTML object from another window

前端 未结 2 1435
自闭症患者
自闭症患者 2020-12-21 05:40

I have an html table from one window. I get the table by using

var table = document.getElementById(\'tableId\');

then I open another windo

相关标签:
2条回答
  • 2020-12-21 06:24

    Problem with above solution is that innerHTML and outerHTML is not supported in IE versions

    0 讨论(0)
  • 2020-12-21 06:27

    IE is probably can't move elements across different documents. What you can do is to user the outerHTML property if the browser fails to clone the table.

    e.g.

    var tbl = window.opener.table;
    try {
        document.getElementById('my_div').appendChild(tbl.cloneNode(true)); 
    }
    catch (e){
        if (tbl.outerHTML) {
            document.getElementById('my_div').innerHTML = tbl.outerHTML;
        }
        else {
                console.log('not working');
        }
    }
    
    0 讨论(0)
提交回复
热议问题