This page is part of the documentation for the Chrome Apps platform, which was deprecated in 2020. Chrome Apps in Kiosk Mode used by Enterprise and Education customers will no longer be supported after April 2027, marking their end of life. Additionally, all remaining Chrome Apps used in managed environments by Enterprise and Education organizations will reach their end of life in October 2028. Learn more about
migrating your app .
資訊清單 - 沙箱
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
重要事項: Chrome 將停止支援所有平台上的 Chrome 應用程式。Chrome 瀏覽器和
Chrome 線上應用程式商店將繼續支援擴充功能。查看公告 並學習
進一步瞭解如何遷移應用程式 。
警告: 自 57 版起,Chrome 將禁止允許外部網路內容 (包括
嵌入頁框或指令碼)。請改用WebView 。
定義要在沙箱專屬來源中提供的一系列應用程式或擴充功能頁面。
以及視需要使用《內容安全政策》進入沙箱有兩個影響:
沙箱頁面無法存取擴充功能或應用程式 API,也無法直接存取
非採用沙箱機制的網頁 (可以透過 postMessage() 與網頁通訊)。
採用沙箱機制的網頁不受其餘部分所使用的內容安全政策 (CSP) 規範。
應用程式或擴充功能 (有專屬的 CSP 值)。也就是說
使用內嵌指令碼和 eval。
以下範例說明如何指定在含有
自訂 CSP:
{
...
"sandbox" : {
"pages" : [
"page1.html" ,
"directory/page2.html"
]
// content_security_policy is optional.
"content_security_policy" :
"sandbox allow-scripts; script-src 'self'"
],
...
}
如未指定,則預設值為 content_security_policy
sandbox allow-scripts allow-forms allow-popups allow-modals; script-src 'self' 'unsafe-inline' 'unsafe-eval'; child-src 'self';。
您可以指定 CSP 值,進一步限製沙箱限制,但其必須具有
sandbox 指令,但不包含 allow-same-origin 符記 (請參閱 HTML5
可能的沙箱權杖的規格 )。此外,您指定的 CSP 可能不允許載入
沙箱模式中的外部網頁內容。
請注意,您只需要列出預期會在視窗或頁框中載入的網頁。資源
沙箱網頁或 JavaScript 來源檔案
sandboxed_page 清單,他們會使用嵌入這些程式的網頁沙箱。
「在 Chrome 擴充功能中使用 eval。 。
採用沙箱機制的工作流程,可以使用原本會發生問題的程式庫
擴充功能的預設內容安全政策 。
只有使用 manifest_version 2 以上版本時,才能指定沙箱頁面。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權 ,程式碼範例則為阿帕契 2.0 授權 。詳情請參閱《Google Developers 網站政策 》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-10-29 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-10-29 (世界標準時間)。"],[],[]]