此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Fence

Limited availability

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

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

围栏框架 APIFence 接口包含与 <fencedframe> 功能相关的几个函数。

Fence 对象可以通过 Window.fence 属性访问,但它们仅对嵌入在 <fencedframe>(通过 FencedFrameConfig 加载)或 <iframe>(通过不透明 URN 加载)中的文档可用。

备注: 参见 <fencedframe> 的工作原理了解有关 FencedFrameConfig 和不透明 URN 的一些描述。

实例方法

getNestedConfigs() 实验性

返回加载到当前 <fencedframe> 内部嵌入的 <fencedframe> 中的 FencedFrameConfig 配置。

reportEvent() 实验性

通过信标触发报告数据的提交,将数据发送到通过受保护的受众 APIregisterAdBeacon() 方法注册的一个或多个特定 URL,以收集广告的竞价结果。

setReportEventDataForAutomaticBeacons() 实验性

指定在 <fencedframe> 内部发生导航时将发送的事件数据。这些数据将通过自动信标发送到通过受保护的受众 APIregisterAdBeacon() 方法注册的一个或多个特定 URL,以收集广告竞价结果的报告数据。

示例

js
window.fence.reportEvent({
  eventType: "click",
  eventData: JSON.stringify({ clickX: "123", clickY: "456" }),
  destination: ["buyer", "seller"],
});

规范

Specification
Fenced Frame
# fence-interface

浏览器兼容性

参见