Enum XFrameOptionsMode
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
XFrameOptionsMode
列舉代表可用於用戶端 HtmlService 指令碼的 X-Frame-Options 模式。這些值可從 HtmlService.XFrameOptionsMode 存取,並透過呼叫 HtmlOutput.setXFrameOptionsMode(mode) 設定。
如要呼叫列舉,請呼叫其父項類別、名稱和屬性。例如
HtmlService.XFrameOptionsMode.ALLOWALL。
設定 XFrameOptionsMode.ALLOWALL 可讓任何網站將網頁設為 iframe,因此開發人員應自行防範點擊劫持。
如果指令碼未設定 X-Frame-Options 模式,應用程式指令碼預設會使用 DEFAULT 模式。
// Serve HTML with no X-Frame-Options header (in Apps Script server-side code).
const output = HtmlService.createHtmlOutput('<b>Hello, world!</b>');
output.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
屬性
| 屬性 | 類型 | 說明 |
ALLOWALL | Enum | 未設定 X-Frame-Options 標頭。這樣任何網站都能將網頁設為 iframe,因此開發人員應自行防範點擊劫持。 |
DEFAULT | Enum | 設定 X-Frame-Options 標頭的預設值,保留一般安全性假設。如果指令碼未設定 X-Frame-Options 模式,Apps Script 會預設使用這個模式。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-03-06 (世界標準時間)。
[null,null,["上次更新時間:2026-03-06 (世界標準時間)。"],[],["`XFrameOptionsMode` is an enum for setting `X-Frame-Options` in client-side HtmlService scripts. Accessed via `HtmlService.XFrameOptionsMode`, it's set using `HtmlOutput.setXFrameOptionsMode(mode)`. `ALLOWALL` removes the `X-Frame-Options` header, enabling any site to iframe the page, necessitating developer-implemented clickjacking protection. `DEFAULT` is the default mode if no mode is specified. The example shows how to set the mode to `ALLOWALL`.\n"]]