CommandEvent: command プロパティ
Baseline
2025
Newly available
Since December 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
command は CommandEvent インターフェイスの読み取り専用プロパティで、イベントが発信された時点での command プロパティの値を含む文字列を返します。
値
文字列です。
例
次の簡単な例では、"show-modal" コマンドを監視するイベントリスナーを設定しています。
js
document.body.addEventListener(
"command",
(event) => {
const theAction = event.command;
if (theAction === "show-modal") {
console.log("モーダルダイアログを表示");
}
},
{ capture: true },
);
仕様書
| Specification |
|---|
| HTML> # dom-commandevent-command> |