HTMLFencedFrameElement: config 屬性
HTMLFencedFrameElement 介面的 config 屬性包含一個 FencedFrameConfig 物件,該物件代表了 <fencedframe> 的導航,即它將顯示什麼內容。FencedFrameConfig 物件通常來自 Protected Audience API 等來源。
值
config 的初始值為 null。
當其值被設定為一個 FencedFrameConfig 物件例項時,FencedFrameConfig 的內部屬性(例如 mappedURL)將決定在關聯的 <fencedframe> 中載入什麼內容。此外
- 導航型別將是
"replace"(參見NavigateEvent.navigationType),這意味著當前歷史記錄條目將被新條目替換,而不是為其新增新的歷史記錄條目。 - 導航的
Referrer-Policy被設定為"no-referrer"。
示例
要設定 <fencedframe> 中將顯示的內容,使用的 API(例如 Protected Audience 或 Shared Storage)會生成一個 FencedFrameConfig 物件,然後將其設定為 <fencedframe> 的 config 屬性的值。
以下示例從 Protected Audience API 的廣告競價中獲取一個 FencedFrameConfig,然後用於在 <fencedframe> 中顯示中標廣告
js
const frameConfig = await navigator.runAdAuction({
// … auction configuration
resolveToConfig: true,
});
const frame = document.createElement("fencedframe");
frame.config = frameConfig;
規範
| 規範 |
|---|
| 圍欄框架 # dom-htmlfencedframeelement-config |
瀏覽器相容性
載入中…
另見
- privacysandbox.google.com 上的Fenced frames
- 隱私沙盒(位於 privacysandbox.google.com)