简体   繁体   English

Internet Explorer 在尝试从另一个窗口附加 HTML 对象时抛出 SCRIPT5022:HierarchyRequestError

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

I have an html table from one window.我有一个窗口中的 html 表。 I get the table by using我通过使用得到表

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

then I open another window by using :然后我使用以下方法打开另一个窗口:

window.open('newWindow.html'); 

In this window, there's a div with id = divId.在这个窗口中,有一个 id = divId 的 div。

Now if I tried to append the table from the other window by the following code :现在,如果我尝试通过以下代码从另一个窗口附加表格:

var cloneTable = jQuery.extend(true, {}, window.opener.table);

var div = document.getElementById('divId');

div.appendChild(cloneTable);

Internet Explorer will throw this error : Internet Explorer 将抛出此错误:

SCRIPT5022: HierarchyRequestError SCRIPT5022:层次结构请求错误

I have searched into the error code, listed here :我搜索了错误代码,这里列出:

http://msdn.microsoft.com/en-us/library/ie/gg592979(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/ie/gg592979(v=vs.85).aspx

It said I can't insert the node at that location.它说我无法在该位置插入节点。 However, the above code works fine in Firefox and Chrome.但是,上面的代码在 Firefox 和 Chrome 中运行良好。

What's happened here and how I can work around it ?这里发生了什么以及我如何解决它?

Thanks,谢谢,

PS: I'm using IE 10 PS:我使用的是 IE 10

IE is probably can't move elements across different documents. IE 可能无法在不同的文档中移动元素。 What you can do is to user the outerHTML property if the browser fails to clone the table.如果浏览器无法克隆表,您可以做的是使用 outerHTML 属性。

eg例如

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');
    }
}

上述解决方案的问题是IE版本不支持innerHTML和outerHTML

This question no longer valid.这个问题不再有效。 Internet Explorer has been retired by Microsoft. Microsoft 已停用 Internet Explorer。 Thanks for all the help.感谢所有的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试在Internet Explorer(IE)上附加jQuery对象时,jQuery抛出SCRIPT5022:HierarchyRequestError - jQuery throws SCRIPT5022: HierarchyRequestError when attempted to append a jQuery object on Internet Explorer ( IE) IE-graphql-SCRIPT5022:无法使用其他模块或领域中的未定义“布尔” - IE - graphql - SCRIPT5022: Cannot use undefined “Boolean” from another module or realm SCRIPT5022:InvalidAccessError xmlhttprequest - SCRIPT5022: InvalidAccessError xmlhttprequest MS Edge:SCRIPT5022:SCRIPT5022:SecurityError - MS Edge: SCRIPT5022: SCRIPT5022: SecurityError 脚本1022:IE 11中的SyntaxError - SCRIPT5022: SyntaxError in IE 11 SCRIPT5022:IE上的WrongDocumentError附加元素 - SCRIPT5022: WrongDocumentError appending element on IE SCRIPT5022:抛出异常但未捕获 - SCRIPT5022: Exception thrown and not caught 获取错误-SCRIPT5022:Sys.WebForms.PageRequestManagerParserErrorException:无法解析从服务器收到的消息 - Getting error - SCRIPT5022: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed postMessage 期间 Microsoft Edge 中的 SCRIPT5022 语法错误 - SCRIPT5022 Syntax Error in Microsoft Edge during postMessage IE10中的Javascript错误(SCRIPT5022) - Javascript error (SCRIPT5022) in IE10
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM