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

View in English Always switch to English

Fence:getNestedConfigs() 方法

Deprecated
To be removed

This feature is pending removal from browsers. Using it now may lead to broken functionality in future updates. Following the announcement that Chrome will maintain its current approach to third-party cookies, Chrome decided to withdraw certain Privacy Sandbox features including the <fencedframe> element and related APIs.

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

Fence 接口的 getNestedConfigs() 方法返回加载到当前 <fencedframe> 内部嵌入的 <fencedframe> 中的 FencedFrameConfig 配置。

语法

js
getNestedConfigs()

参数

无。

返回值

getNestedConfigs() 有两个可能的返回值:

  • 如果当前 <fencedframe> 的配置是通过支持嵌套配置的 API(例如受保护的受众)创建的,则为一个包含 20 个 FencedFrameConfig 对象的数组。在这 20 个配置中,前 N 个配置是通过 API 注册的,其余的是将导航到 about:blank 的填充配置,以便隐藏配置的数量并防止任何信息泄露。
  • 如果当前 <fencedframe> 的配置是通过不支持嵌套配置的 API(例如共享存储)创建的,则为 null

示例

js
// 在 <fencedframe> 内部运行

// 获取嵌入围栏框架的配置
const configs = window.fence.getNestedConfigs();

// 将新的围栏框架配置设置为与检索到的某个配置相同
const frame = document.createElement("fencedframe");
frame.config = configs[0];

规范

规范
Fenced Frame
# dom-fence-getnestedconfigs

浏览器兼容性

参见