javascript - 仅在 iframe 上关闭 javascript

标签 javascript

有没有办法让<iframe>中的页面标签不能使用javascript?

仅在 iframe 上关闭 javascript,但不在浏览器上关闭。

最佳答案

设置sandbox attribute在 iframe 上。

<iframe sandbox></iframe>

The sandbox attribute, when specified, enables a set of extra restrictions on any content hosted by the iframe. Its value must be an unordered set of unique space-separated tokens that are ASCII case-insensitive. The allowed values are allow-same-origin, allow-top-navigation, allow-forms, and allow-scripts. When the attribute is set, the content is treated as being from a unique origin, forms and scripts are disabled, links are prevented from targeting other browsing contexts, and plugins are disabled. The allow-same-origin keyword allows the content to be treated as being from the same origin instead of forcing it into a unique origin, the allow-top-navigation keyword allows the content to navigate its top-level browsing context, and the allow-forms and allow-scripts keywords re-enable forms and scripts respectively (though scripts are still prevented from creating popups).

关于javascript - 仅在 iframe 上关闭 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3384602/

相关文章:

javascript - 自动完成显示所有结果

javascript - 无法加载资源,即使它在那里

javascript - 替换 html 元素的字符串

javascript - 以编程方式创建 Bootstrap 选项卡

javascript - 如何根据名称升序和降序对列进行排序

javascript - REACT-Toastify - 重复 toast

javascript - 自动登录 chrome 扩展

javascript用0填充输入值直到最大长度

javascript - 谷歌地图绘制两点之间的路线

javascript - 如何循环遍历数组并在每个项目之间等待一段时间?