0
我试图从iFrame中删除内容,并且我得到这个问题:Unloading/Removing content from an iFrame。 问题是,当我试图编写给定的解决方案时,FireBug中的调试控制台上出现此错误:Permission denied to access property 'document'
。尝试“从iFrame卸载/删除内容”时出错
我在做什么,这是:
var frame = document.getElementById("idFrame"),
frameDoc = frame.contentDocument || frame.contentWindow.document; //error here
frameDoc.removeChild(frameDoc.documentElement);
这里有什么问题吗?我做错了什么?
同样的错误,当我试图做的事:
$("#amadeusFrame").contents().find("body").html('');
跨域访问?如果是,[同源策略](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript)会阻止对iframe的访问。 – Teemu
完全像@泰姆说的 - 阅读关于接受Teemu问题的答案的第三条评论。当然,如果你想消除iframe中的所有内容,试试我的解决方案。 – ElmoVanKielmo