有没有办法让<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/