列舉代表可用於用戶端 HtmlService 指令碼的 X-Frame-Options 模式。這些值可從 HtmlService.XFrameOptionsMode 存取,並透過呼叫 HtmlOutput.setXFrameOptionsMode(mode) 設定。
如要呼叫列舉,請呼叫其父項類別、名稱和屬性。例如
HtmlService.XFrameOptionsMode.ALLOWALL。
設定 XFrameOptionsMode.ALLOWALL 可讓任何網站將網頁設為 iframe,因此開發人員應自行防範點擊劫持。
如果指令碼未設定 X-Frame-Options 模式,Apps Script 會預設使用 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 會預設使用這個模式。 |