HTMLFencedFrameElement

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

實驗性: 這是一項實驗性技術
在生產中使用此技術之前,請仔細檢查瀏覽器相容性表格

HTMLFencedFrameElement 介面表示 JavaScript 中的 <fencedframe> 元素,並提供配置屬性。

EventTarget Node Element HTMLElement HTMLFencedFrameElement

例項屬性

繼承自其父級 HTMLElement 的屬性。

HTMLFencedFrameElement.allow 實驗性

獲取和設定相應的 <fencedframe> allow 屬性的值。該屬性表示在內容首次嵌入時應用的 許可權策略

HTMLFencedFrameElement.config 實驗性

一個 FencedFrameConfig 物件,它代表 <fencedframe> 的導航,即將在其中顯示的內容。FencedFrameConfig 可以從 Protected Audience API 等來源獲取。

HTMLFencedFrameElement.height 實驗性

獲取和設定相應的 <fencedframe> height 屬性的值,該屬性指定元素的高度。

HTMLFencedFrameElement.width 實驗性

獲取和設定相應的 <fencedframe> width 屬性的值,該屬性指定元素的寬度。

示例

要設定 <fencedframe> 中將顯示的內容,使用的 API(例如 Protected AudienceShared 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;

注意:必須將 resolveToConfig: true 傳遞給 runAdAuction() 呼叫才能獲取 FencedFrameConfig 物件。如果未設定,結果的Promise 將解析為一個 URN,該 URN 只能在<iframe> 中使用。

規範

規範
圍欄框架
# htmlfencedframeelement

瀏覽器相容性

另見