Document:pictureInPictureElement 属性
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Document 接口的 pictureInPictureElement 只读属性返回当前文档中以画中画模式呈现的 Element,如果没有使用画中画模式,则返回 null。
尽管这个属性是只读的,但是即使它被修改(甚至是在严格模式下),也不会抛出错误;setter 是无操作的并且将会被忽略。
值
对当前处于画中画模式的 Element 对象的引用。
如果文档没有处于画中画模式的相关元素,则返回 null。例如,没有画中画元素,或者画中画元素来自 iframe 中。
示例
此示例展示了一个 exitPictureInPicture() 函数,该函数的运行由 pictureInPictureElement 的返回值决定。如果文档处于画中画模式(pictureInPictureElement 不是 null),Document.exitPictureInPicture() 将被运行以退出画中画模式。
js
function exitPictureInPicture() {
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
}
规范
| Specification |
|---|
| Picture-in-Picture> # dom-documentorshadowroot-pictureinpictureelement> |
浏览器兼容性
Loading…