所以我只想在 iframe 中沙箱一个 html 文件,只要有allow-scripts属性它就可以工作,但只要我添加allow-same-origin它就停止工作,因为:
\n\n\n有关沙箱的注意事项:\n 当嵌入文档与嵌入页面具有相同来源时,强烈建议不要同时使用allowed-scripts和allowed-same-origin,因为这会让嵌入文档删除沙箱属性\xe2\x80 \x94 使其并不比根本不使用沙箱属性更安全。\n 如果攻击者可以在沙箱 iframe \xe2\x80\x94 之外显示内容(例如查看者在新选项卡中打开该框架),则沙箱是无用的。此类内容还应从单独的源提供,以限制潜在的损害。\n Internet Explorer 9 及更早版本不支持沙箱属性。来自:
\n
\n https://developer.mozilla.org/en-US/docs/Web /HTML/元素/iframe
iframe代码:
\n\n<iframe src="index.html" sandbox=\'allow-scripts allow-same-origin\'></frame>\nRun Code Online (Sandbox Code Playgroud)\n\n我想要,allow-same-origin因为我想在 iframe 中使用与 index.html 中相同的 css。
html iframe sandbox firefox-addon firefox-addon-webextensions