<button commandfor="mypopover" command="toggle-popover">
Toggle the popover
</button>
<div id="mypopover" popover>
<button commandfor="mypopover" command="hide-popover">Close</button>
Popover content
</div>Invoker Commands API / notebook
Invoker Commands API
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
<button commandfor="mydialog" command="show-modal">Show modal dialog</button>
<dialog id="mydialog">
<button commandfor="mydialog" command="close">Close</button>
Dialog Content
</dialog><button commandfor="my-img" command="--rotate-left">Rotate left</button>
<button commandfor="my-img" command="--rotate-right">Rotate right</button>
<img id="my-img" src="photo.jpg" alt="[add appropriate alt text here]" />const myImg = document.getElementById("my-img");
myImg.addEventListener("command", (event) => {
if (event.command === "--rotate-left") {
myImg.style.rotate = "-90deg";
} else if (event.command === "--rotate-right") {
myImg.style.rotate = "90deg";
}
});