Non-standard
This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.
This API is available on Firefox OS for privileged or certified applications only.
The getVolume()
method of the HTMLIFrameElement
gets the current volume of the browser <iframe>
.
SyntaxEdit
There are two versions of this method, a callback version:
var request = instanceOfHTMLIframeElement.getVolume();
and a Promise
version:
instanceOfHTMLIframeElement.getVolume().then(function(volume) { ... });
Returns
- Callback version: A
DOMRequest
that represents the get volume request. It has anonsuccess
handler to handle the success case, and anonerror
handler to handle the failure case. The volume value is available in therequest.result
property, and is a floating point number between 0 and 1. - Promise version: A
Promise
that resolves with the volume value — a floating point number between 0 and 1.
Parameters
None.
ExampleEdit
Callback version:
var browser = document.querySelector('iframe');
var request = browser.getVolume();
request.onsuccess = function() {
console.log('The current browser volume is ' + request.result);
}
Promise
version:
var browser = document.querySelector('iframe');
browser.getVolume().then(function(volume) {
console.log('The current browser volume is ' + volume);
});
SpecificationEdit
Not part of any specification.
Browser compatibilityEdit
Note: Use of the Browser API requires a privileged app, and browser
and/or embed-apps
permissions, depending on what you want to do. See Using the Browser API for more details.