我在 iframe(同源)中使用以下 jQuery 代码来尝试将节点从 iframe 移动到主(顶部)文档。
var dest = $(window.top.document).find('#dest_id');
dest.append($('#source_id'));
以下工作正常:
window.top.document.getElementById('dest_id').innerHTML = document.getElementById('source_id').innerHTML;
我猜想在帧之间移动 DOM 节点是有限制的。在普通的js或jquery中有没有办法解决这个问题?
编辑:这可能与ownerDocument
财产有关吗?我尝试将其更改为window.top.document
#dest_id 但没有奏效。
编辑,类似的问题:Can't appendChild to a node created from another frame