const popover = document.getElementById("mypopover");
// …
popover.addEventListener("command", (event) => {
if (event.command === "show-popover") {
console.log("Popover is about to be shown");
}
});HTMLElement: command event / notebook
HTMLElement: command event
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
button.addEventListener("click", (event) => {
event.preventDefault(); // the `command` event will never fire
});element.addEventListener("command", (event) => {
event.preventDefault(); // the `command` event fires but the default behavior is canceled
});