W3cubDocs

/Web APIs

Fence

Limited availability

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

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The Fence interface of the Fenced Frame API contains several functions relevant to <fencedframe> functionality.

Fence objects are accessed through the Window.fence property, but they are only available to documents embedded inside <fencedframe>s (loaded via FencedFrameConfigs) or <iframe>s (loaded via opaque URNs).

Note: See How do <fencedframe>s work? for some description around FencedFrameConfigs and opaque URNs.

Instance methods

getNestedConfigs() Experimental

Returns the FencedFrameConfigs loaded into <fencedframe>s embedded inside the current <fencedframe>.

reportEvent() Experimental

Triggers the submission of report data via a beacon to one ore more specific URLs registered via the registerAdBeacon() method of the Protected Audience API, for the purpose of collecting ad auction results.

setReportEventDataForAutomaticBeacons() Experimental

Specifies event data that will be sent when a navigation occurs inside a <fencedframe>. This data will be sent via an automatic beacon to one or more specific URLs registered via the registerAdBeacon() method of the Protected Audience API, for the purpose of collecting reporting data for ad auction results.

Examples

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

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
Fence 126 126 No 112 No 126 No 83 No 28.0 126 No
getNestedConfigs 126 126 No 112 No 126 No 83 No 28.0 126 No
reportEvent 126 126 No 112 No 126 No 83 No 28.0 126 No
setReportEventDataForAutomaticBeacons 126 126 No 112 No 126 No 83 No 28.0 126 No

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Fence