DocumentPictureInPicture: requestWindow() method

Limited availability

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

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The requestWindow() method of the DocumentPictureInPicture interface opens the Picture-in-Picture window for the current main browsing context. It returns a Promise that fulfills with a Window instance representing the browsing context inside the Picture-in-Picture window.

The requestWindow() method requires transient activation, i.e., it must be invoked in response to a user action such as a mouse click or button press.

Syntax

js
requestWindow()
requestWindow(options)

Parameters

options Optional

An options object containing the following properties:

disallowReturnToOpener Optional

A boolean value. When set to true, this option hints to the browser that it should not display a UI control that enables the user to return to the originating tab and close the Picture-in-Picture window. Defaults to false.

For example, in Chrome's implementation of this feature, the provided UI control is a "back to tab" button in the Picture-in-Picture window's top bar:

browser window containing an embedded video player and multiple control buttons, with a back to tab button in the top bar, highlighted with a red box

height Optional

A non-negative number representing the height to set for the Picture-in-Picture window's viewport, in pixels. Defaults to 0.

preferInitialWindowPlacement Optional

A boolean value, which defaults to false. When set to true, it causes the Picture-in-Picture window to always appear back at the position and size it initially opened at, when it is closed and then reopened. By contrast, if preferInitialWindowPlacement is false the Picture-in-Picture window's size and position will be remembered when closed and reopened — it will reopen at its previous position and size, for example as set by the user.

width Optional

A non-negative number representing the width to set for the Picture-in-Picture window's viewport, in pixels. Defaults to 0.

Note: If one of height or width is specified, the other one must be too, otherwise an error is thrown. If both values are not specified, specified as 0, or set too large, the browser will clamp or ignore the values as appropriate to provide a reasonable user experience. The clamped size will vary depending on implementation, display size, and other factors.

Return value

A Promise that fulfills with a Window object instance representing the browsing context inside the Picture-in-Picture window.

Exceptions

NotSupportedError DOMException

Thrown if the API has been explicitly disabled (for example via browser settings).

NotAllowedError DOMException

Thrown if:

RangeError DOMException

Thrown if only one of height and width are set, or if height and width are set with negative values.

Examples

js
const videoPlayer = document.getElementById("player");

// …

// Open a Picture-in-Picture window with all options set
const pipWindow = await window.documentPictureInPicture.requestWindow({
  width: videoPlayer.clientWidth,
  height: videoPlayer.clientHeight,
  disallowReturnToOpener: true,
  preferInitialWindowPlacement: true,
});

// …

Specifications

Specification
Document Picture-in-Picture Specification
# dom-documentpictureinpicture-requestwindow

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
requestWindow
Chrome – Full support
Chrome 116 (Release date: 2023-08-15)
footnote Full support
Edge – Full support
Edge 116 (Release date: 2023-08-21)
footnote Full support
Firefox – Preview support
Firefox 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera – Full support
Opera 102 (Release date: 2023-08-23)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – Preview support
Firefox for Android 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
disallowReturnToOpener option
Chrome – Full support
Chrome 124 (Release date: 2024-04-16)
footnote Full support
Edge – Full support
Edge 124 (Release date: 2024-04-18)
footnote Full support
Firefox – Preview support
Firefox 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera – Full support
Opera 110 (Release date: 2024-05-14)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – Preview support
Firefox for Android 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support
preferInitialWindowPlacement option
Chrome – Full support
Chrome 130 (Release date: 2024-10-15)
footnote Full support
Edge – Full support
Edge 130 (Release date: 2024-10-17)
footnote Full support
Firefox – Preview support
Firefox 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera – Full support
Opera 115 (Release date: 2024-11-27)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – No support
Chrome Android
footnote No support
Firefox for Android – Preview support
Firefox for Android 151 (Release date: 2026-05-19)
footnote Preview browser support
Opera Android – No support
Opera Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – No support
WebView Android
footnote No support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support

See also