Skip to main content
command | oncommand event

Fired whenever a user interface (UI) action takes place.

Syntax

HTML Attribute <element oncommand = "handler(event)">
addEventListener Method object.addEventListener("command", handler, useCapture)

 

Event information

SynchronousYes
BubblesYes
CancelableYes

 

Event handler parameters

event

Type: CommandEvent

Remarks

This event provides a hook into the UI action currently taking place, allowing you to update the page state and UI and / or prevent default event behavior.

The command is fired for all of the following Windows UI Automation (UIA) methods:

commandName UIA Method
toggle IToggleProvider::Toggle
expand IExpandCollapseProvider::Expand
collapse IExpandCollapseProvider::Collapse
scrollIntoView IScrollItemProvider::ScrollIntoView
select ISelectionItemProvider::Select
addToSelection ISelectionItemProvider::AddToSelection
removeFromSelection ISelectionItemProvider::RemoveFromSelection
setValue IValueProvider::SetValue
scrollHorizontal IScrollProvider::Scroll
scrollVertical IScrollProvider::Scroll
setHorizontalScrollPercent IScrollProvider::SetScrollPercent

 

Examples


function handleCommand(evt) {
    var myContainer = document.getElementById("content");
    if (evt.target == myContainer && evt.commandName == "toggle") {
        evt.preventDefault();
    }
}

See also

Element
ariarequest