The popover
property of the HTMLElement
interface gets and sets an element's popover state via JavaScript ("auto"
or "manual"
), and can be used for feature detection.
It reflects the value of the popover
global HTML attribute.
The popover
property of the HTMLElement
interface gets and sets an element's popover state via JavaScript ("auto"
or "manual"
), and can be used for feature detection.
It reflects the value of the popover
global HTML attribute.
An enumerated value; possible values are:
"auto"
: In auto state: "manual"
: In manual state: You can use the popover
attribute to feature detect the Popover API:
js
function supportsPopover() { return HTMLElement.prototype.hasOwnProperty("popover"); }
js
const popover = document.getElementById("mypopover"); const toggleBtn = document.getElementById("toggleBtn"); const popoverSupported = supportsPopover(); if (popoverSupported) { popover.popover = "auto"; toggleBtn.popoverTargetElement = popover; toggleBtn.popoverTargetAction = "toggle"; } else { console.log("Popover API not supported."); }
Specification |
---|
HTML Standard # dom-popover |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
popover |
114 | 114 | 114 | No | 100 | 17 | 114 | 114 | No | No | 17 | No |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/popover