HTML <iframe> 标签sandbox属性
-
<iframe>标签sandbox属性定义和用法
sandbox属性为iframe中的内容启用了一组额外的限制。
当sandbox属性存在时,它将:- 将内容视为来自独特的来源
- 阻止表单提交
- 阻止脚本执行
- 禁用API
- 阻止链接定位到其他浏览上下文
- 阻止内容使用插件(通过<embed>,<object>,<applet>或其他)
- 阻止内容导航其顶级浏览上下文
- 阻止自动触发的功能(例如自动播放视频或自动聚焦表单控件)
-
<iframe>标签sandbox属性浏览器支持
Edge/IE Chrome FireFox Safari Opera 10.0(含)以上 4.0(含)以上 17.0(含)以上 5.0(含)以上 15.0(含)以上 -
HTML4.01和HTML5之间的差异
sandbox属性是HTML5中的新属性。
-
<iframe>标签sandbox属性语法
<iframe sandbox="value"> -
-
<iframe>标签sandbox属性值
属性值 描述 (no value) 适用所有限制 allow-forms 重新启用表单提交 allow-pointer-lock 重新启用API allow-popups 重新启用弹出窗口 allow-same-origin 允许将iframe内容视为来自同一来源 allow-scripts 重新启用脚本 allow-top-navigation 允许iframe内容导航其顶级浏览上下文