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 getScreenshot() method of the HTMLIFrameElement lets you request a screenshot of an content <iframe>, scaled to fit within a specified maximum width and height. The image will be cropped if necessary but will not be distorted vertically or horizontally.

Note: getScreenshot() waits for the event loop to go idle before it takes the screenshot. It won't wait more than 2000ms (this delay is defined by the Gecko dom.browserElement.maxScreenshotDelayMS preference).


var instanceOfDOMRequest =
instanceOfHTMLIframeElement.getScreenshot(maxWidth, maxHeight, mimeType);


A DOMRequest for handling the screenshot request. Its request.onsuccess handler handles the success case (the screenshot is contained in request.result as a Blob object), and its request.onerror handler handles the failure case.


A number representing the maximum width of the screenshot in device pixels.
A number representing the maximum height of the screenshot in device pixels.
mimeType Optional
A MIME type specifying the format of the image to be returned; if not specified, the default used is image/jpeg. Use image/png to capture the alpha channel of the rendered result by returning a PNG-format image. This lets you get a transparent background for the content <iframe>.


var browser = document.querySelector('iframe');

var request = browser.getScreenshot(100, 100);

request.onsuccess = function() {
  var blob = request.result;
  var url = URL.createObjectURL(blob);


Not part of any specification.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support Not supported Not supported Not supported Not supported Not supported
Feature Android Firefox Mobile (Gecko) Firefox OS (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support Not supported Not supported 1.0.1 Not supported Not supported Not supported

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.

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API B2G Browser Firefox OS getScreenshot HTML DOM HTMLIFrameElement Method Non-standard Reference Référence