HTMLFencedFrameElement:config 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

HTMLFencedFrameElementconfig 属性包含一个 FencedFrameConfig 对象,表示 <fencedframe> 的导航,即其中将显示什么内容。FencedFrameConfig 是从诸如受保护的受众 API 等来源返回的。

config 的初始值为 null

当值设置为 FencedFrameConfig 对象实例,FencedFrameConfig 的内部属性(例如 mappedURL)将决定所关联的 <fencedframe> 内部加载的内容。此外:

  • 导航类型将是 "replace"(参见 NavigateEvent.navigationType),这意味着当前历史记录条目将被新条目替换,而不是为其添加一个新的历史记录条目。
  • 导航的 Referrer-Policy 被设置为 "no-referrer"

示例

要设置将在 <fencedframe> 中显示的内容,使用 API(如受保护的受众共享存储)生成一个 FencedFrameConfig 对象,然后将其设置为 <fencedframe>config 属性值。

以下示例从受保护的受众 API 的广告拍卖中获取一个 FencedFrameConfig,然后使用它在 <fencedframe> 中显示获胜的广告:

js
const frameConfig = await navigator.runAdAuction({
  // 拍卖配置
  resolveToConfig: true,
});

const frame = document.createElement("fencedframe");
frame.config = frameConfig;

备注: 在调用 runAdAuction() 时,必须传入 resolveToConfig: true 以获得 FencedFrameConfig 对象。如果没有设置,则所得的 Promise 将兑现为一个 URN,该 URN 只能在 <iframe> 中使用。

规范

Specification
Fenced Frame
# dom-htmlfencedframeelement-config

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
config
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.

参见