?
This document uses PHP Chinese website manual Release
HTTP Content-Security-Policy
(CSP)sandbox
偽指令為請求的資源啟用類似于<iframe>
sandbox
屬性的沙箱。它對頁面的操作應用限制,包括阻止彈出窗口,阻止插件和腳本的執(zhí)行以及強制執(zhí)行同源策略。
CSP版本 | 1.1 / 2 |
---|---|
指令類型 | Document指令 |
| 此指令在<meta>元素或Content-Security-policy-Report-Only標題字段中不受支持。|
Content-Security-Policy: sandbox;Content-Security-Policy: sandbox <value>;
where <value>
can optionally be one of the following values:
allow-forms
允許嵌入式瀏覽上下文提交表單。如果未使用此關(guān)鍵字,則不允許此操作。
allow-modals
允許嵌入式瀏覽上下文打開模態(tài)窗口。
allow-orientation-lock
允許嵌入式瀏覽上下文禁用鎖定屏幕方向的功能。
allow-pointer-lock
允許嵌入式瀏覽上下文使用指針鎖定API。
allow-popups
允許彈出窗口(像window.open
,target="_blank"
,showModalDialog
)。如果未使用此關(guān)鍵字,則該功能將悄然失敗。
allow-popups-to-escape-sandbox
允許沙盒文檔打開新窗口而不強制沙盒標記。例如,這將允許第三方廣告安全地進行沙盒處理,而不會對登錄頁面強加相同的限制。
allow-presentation
允許嵌入程序控制iframe是否可以啟動演示會話。
allow-same-origin
允許將內(nèi)容視為來自其正常來源。如果未使用此關(guān)鍵字,則將嵌入內(nèi)容視為來自唯一來源。
allow-scripts
允許嵌入式瀏覽上下文運行腳本(但不能創(chuàng)建彈出窗口)。如果未使用此關(guān)鍵字,則不允許此操作。
allow-top-navigation
允許嵌入式瀏覽上下文將內(nèi)容導航(加載)到頂層瀏覽上下文。如果未使用此關(guān)鍵字,則不允許此操作。
Content-Security-Policy: sandbox allow-scripts;
規(guī)范 | 狀態(tài) | 評論 |
---|---|---|
內(nèi)容安全策略級別3該規(guī)范中“sandbox”的定義。 | 編輯草稿 | 沒有變化。 |
內(nèi)容安全策略級別2該規(guī)范中“sandbox”的定義。 | 建議 | 初始定義。 |
特征 | Chrome | Firefox | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
基本支持 | 25 | 50.0 | 14 | 10 | 15 | 7 |
特征 | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
基本支持 | 4.4 | (Yes) | ? | 50.0 | 10 | ? | 7.1 |