javascript - 如何使用 javascript 以编程方式从 iframe 中删除沙箱属性

标签 javascript jquery html google-chrome

我认为这是不可能的,但是,我发现了这句话:

"It is strongly discouraged to use both allow-scripts and allow-same-origin at the same time, as that allows the embedded document to programmatically remove the sandbox attribute."

我的 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/

相关文章:

javascript - Node.js,多个 MySQL 插入

javascript - 出现 CSS 行

html - 显示问题 CSS

html - 段落 float 有问题,只有一些文本有边框

javascript - Meteor:从集合中的文档中检索值

javascript - 如何使 iframe 分辨率响应以完全适应它所在的 iframe?

javascript - 尝试从集合中获取特定模型

jquery - header、container 和 footer 需要包含整个布局而不使用固定位置

javascript - 页面加载后运行脚本而不使用 onload 函数

javascript - 为什么单击弹出按钮时 div 位置会发生变化?