大网数据广告活动
Web 标准与前端开发

Presentation: receiver property

· 52CE 我爱测

The **read-only** Presentation attribute `receiver`, which is only available in browser contexts which are **receiving** a presentation, returns the PresentationReceiver object which can be used to access and communicate with the browser context which controls the presentation. T

Presentation

The read-only Presentation attribute receiver, which is only available in browser contexts which are receiving a presentation, returns the PresentationReceiver object which can be used to access and communicate with the browser context which controls the presentation. This property is always null when accessed from outside a browser context which is receiving a presentation.

Value

If the code is running in a context which is receiving a presentation, the returned value is a PresentationReceiver which can then be used to communicate with the context which is the source of the presentation.

If the current context is not receiving a presentation, receiver is null.

Examples

Determining whether or not the context is receiving a presentation

You can easily determine whether or not the context is the receiver for a presentation by checking the value of navigator.presentation.receiver. If it's a non-null value, then the context is indeed receiving a presentation. If it's null, there's no incoming presentation.

footer.textContent = navigator.presentation.receiver
  ? "Receiving presentation"
  : "(idle)";

Accessing the connection list

This example uses receiver to access the list of incoming connections and to build and display a list of those connections' ID strings.

const listElem = document.getElementById("connection-view");

navigator.presentation.receiver.connectionList.then((connections) => {
  connections.forEach((connection) => {
    listElem.appendChild(document.createElement("li")).textContent =
      connection.id;
  });
});

After getting access to the output list element in the variable connectionView, navigator.presentation.receiver is used to get a reference to the PresentationReceiver object for this context, and its PresentationReceiver.connectionList is used to get a Promise which will be called when the list is available.

The promise handler receives as its input parameter an array of the incoming connections. We iterate over these using Array.forEach, appending a new item to the connectionView list element for each connection.

Specifications

Browser compatibility

See also

  • Presentation API
  • Presentation
  • PresentationReceiver

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。