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.
Syntax
receiver = Presentation.receiver; receiver = navigator.presentation.receiver;
Since the Presentation
interface is typically accessed through navigation.presentation
, the second form of the syntax shown above is the more commonly used.
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
.
Example
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.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.
if (navigator.receiver) {
footer.innerHTML = "Receiving presentation";
} else {
footer.innerHTML = "(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.
let listElem = document.getElementById("connectionview");
navigator.presentation.receiver.connectionList
.then(function(connections) {
connections.forEach(function(aConnection)) {
listElem.innerHTML += "<li>" + aConnection.id
+ "</li>";
});
});
After getting access to the output list element in the variable connectionView
, navigator.receiver
is used to get a reference to the PresentationReceiver
object for this context, and its 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 forEach()
, appending a new item to the connectionView
list element for each connection.
Specifications
Specification | Status | Comment |
Presentation APIThe definition of 'receiver' in that specification. | Candidate Recommendation |
Browser Compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
Full support 48 |
Edge
Full support ≤79 |
Firefox Full support 51 Full support 51 Disabled' From version 51: this feature is behind the |
IE
No support No |
Opera
Full support Yes |
Safari
? |
WebView Android
No support No |
Chrome Android
Full support 48 |
Firefox Android Full support 51 Full support 51 Disabled' From version 51: this feature is behind the |
Opera Android
Full support Yes |
Safari iOS
? |
Samsung Internet Android
Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
See also
- Presentation API
Presentation
PresentationReceiver
Presentation.receiver by Mozilla Contributors is licensed under CC-BY-SA 2.5.