Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Presentation
  4. receiver

Presentation: receiver property

Limited availability

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

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.

Theread-onlyPresentation attributereceiver, which is only available in browser contexts which arereceiving a presentation, returns thePresentationReceiver object which can be used to access and communicatewith the browser context which controls the presentation. This property is alwaysnull when accessed from outside a browser context which is receiving apresentation.

Value

If the code is running in a context which is receiving a presentation, the returnedvalue is aPresentationReceiver which can then be used to communicatewith the context which is the source of the presentation.

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

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 presentationby checking the value ofnavigator.presentation.receiver. If it's a non-null value, thenthe context is indeed receiving a presentation. If it'snull, there's noincoming presentation.

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

Accessing the connection list

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

js
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 variableconnectionView,navigator.presentation.receiver is used to get areference to thePresentationReceiver object for this context, and itsconnectionList is used to get aPromise which will be called when the list is available.

The promise handler receives as its input parameter an array of the incomingconnections. We iterate over these usingforEach(),appending a new item to theconnectionView list element for eachconnection.

Specifications

Specification
Presentation API
# dom-presentation-receiver

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp