我认为这是不可能的,但是,我发现了这句话:
我的 iframe 需要有一个沙箱,但只有当我在某些 URL 中浏览时,嵌入式浏览上下文会尝试将内容导航(加载)到顶级浏览上下文(跳出框架...)
在其他页面上,沙箱需要完全删除,因为它不允许我浏览不同来源的网站...
The frame attempting navigation is sandboxed, and is therefore disallowed from navigating its ancestors.
以编程方式更改沙箱:
document.getElementById("frame").sandbox = "";
...也不起作用,因为这仍然存在限制...因此,我需要以某种方式完全删除该属性,我该怎么做呢?
最佳答案
These flags only take effect when the nested browsing context of the iframe is navigated. Removing them, or removing the entire sandbox attribute, has no effect on an already-loaded page.
更多信息 - Here
关于javascript - 如何使用 javascript 以编程方式从 iframe 中删除沙箱属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16135465/