小编Mar*_*der的帖子

如何让allow-scripts和allow-same-origin在iframe中共存?

所以我只想在 iframe 中沙箱一个 html 文件,只要有allow-scripts属性它就可以工作,但只要我添加allow-same-origin它就停止工作,因为:

\n\n
\n

有关沙箱的注意事项:\n 当嵌入文档与嵌入页面具有相同来源时,强烈建议不要同时使用allowed-scriptsallowed-same-origin因为这会让嵌入文档删除沙箱属性\xe2\x80 \x94 使其并不比根本不使用沙箱属性更安全。\n 如果攻击者可以在沙箱 iframe \xe2\x80\x94 之外显示内容(例如查看者在新选项卡中打开该框架),则沙箱是无用的。此类内容还应从单独的源提供,以限制潜在的损害。\n Internet Explorer 9 及更早版本不支持沙箱属性。来自:
\n https://developer.mozilla.org/en-US/docs/Web /HTML/元素/iframe

\n
\n\n

iframe代码:

\n\n
<iframe src="index.html" sandbox=\'allow-scripts allow-same-origin\'></frame>\n
Run Code Online (Sandbox Code Playgroud)\n\n

我想要,allow-same-origin因为我想在 iframe 中使用与 index.html 中相同的 css。

\n

html iframe sandbox firefox-addon firefox-addon-webextensions

7
推荐指数
1
解决办法
3万
查看次数