Enum XFrameOptionsMode
XFrameOptionsMode
Một enum đại diện cho các chế độ X-Frame-Options
có thể được dùng cho tập lệnh HtmlService
phía máy khách. Bạn có thể truy cập vào các giá trị này từ HtmlService.XFrameOptionsMode
và đặt bằng cách gọi HtmlOutput.setXFrameOptionsMode(mode)
.
Để gọi một enum, bạn gọi lớp mẹ, tên và thuộc tính của enum đó. Ví dụ:
HtmlService.XFrameOptionsMode.ALLOWALL
.
Việc đặt XFrameOptionsMode.ALLOWALL
sẽ cho phép mọi trang web tạo iframe cho trang, vì vậy, nhà phát triển nên triển khai biện pháp bảo vệ riêng để chống lại hành vi nhấp giả.
Nếu tập lệnh không đặt chế độ X-Frame-Options
, thì Apps Script sẽ sử dụng chế độ DEFAULT
làm chế độ mặc định.
// 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);
Thuộc tính
Thuộc tính | Loại | Mô tả |
ALLOWALL | Enum | Không đặt tiêu đề X-Frame-Options . Điều này sẽ cho phép mọi trang web tạo iframe cho trang, vì vậy, nhà phát triển nên triển khai biện pháp bảo vệ riêng để chống lại hành vi nhấp giả. |
DEFAULT | Enum | Đặt giá trị mặc định cho tiêu đề X-Frame-Options , giúp giữ nguyên các giả định bảo mật thông thường. Nếu một tập lệnh không đặt chế độ X-Frame-Options , thì Apps Script sẽ sử dụng chế độ này làm chế độ mặc định. |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2024-12-22 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2024-12-22 UTC."],[[["`XFrameOptionsMode` is used to control how a client-side Apps Script HTML service can be embedded in iframes by other websites."],["`ALLOWALL` permits any website to embed the page in an iframe while `DEFAULT` preserves the standard security behavior."],["If you select `ALLOWALL`, ensure to incorporate your own security measures against clickjacking."],["By default, if `X-Frame-Options` mode isn't specifically set, Apps Script automatically applies the `DEFAULT` mode."]]],["`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"]]