a
element to define a commandbutton
element to define a commandinput
element to define a commandoption
element to define a commandcommand
element to define
a commandaccesskey
attribute on a label
element to define a commandaccesskey
attribute on a legend
element to define a commandaccesskey
attribute to define a command on other elementsA command is the abstraction behind menu items, buttons, and links.
Commands are defined to have the following facets:
These facets are exposed on elements using the command API:
commandType
Exposes the Type facet of the command.
id
Exposes the ID facet of the command.
label
Exposes the Label facet of the command.
title
Exposes the Hint facet of the command.
icon
Exposes the Icon facet of the command.
accessKeyLabel
Exposes the Access Key facet of the command.
hidden
Exposes the state of the element's hidden
attribute, which is generally
equivalent to the Hidden
State facet of the command. For label
and
legend
elements (used in conjunction with the accesskey
attribute), the Hidden State facet is
derived from another element (the one that the assigned
access key will trigger), and cannot be directly accessed
from the element.
disabled
Exposes the Disabled State facet of the command.
checked
Exposes the Checked State facet of the command.
click
()Triggers the Action of the command.
The commandType
attribute must return a string whose value is either "command
", "radio
", or "checkbox
", depending on whether the Type of the command defined by the
element is "command", "radio", or "checkbox" respectively. If the
element does not define a command, it must return null.
The label
attribute must return the command's Label, or null if the element
does not define a command or does not specify a Label. This attribute will be
shadowed by the label
IDL attribute on
various elements.
The icon
attribute must return the absolute URL of the command's
Icon. If the element does
not specify an icon, or if the element does not define a command,
then the attribute must return null. This attribute will be shadowed
by the icon
IDL attribute on
command
elements.
The disabled
attribute must return true if the command's Disabled State is that
the command is disabled, and false if the command is not
disabled. This attribute is not affected by the command's Hidden State. If the
element does not define a command, the attribute must return
false. This attribute will be shadowed by the disabled
IDL attribute on various elements.
The checked
attribute
must return true if the command's Checked State is that the
command is checked, and false if it is that the command is not
checked. If the element does not define a command, the attribute
must return false. This attribute will be shadowed by the checked
IDL attribute on input
and
command
elements.
The ID facet
is exposed by the id
IDL attribute,
the Hint facet is exposed by
the title
IDL attribute, the AccessKey facet is exposed by
the accessKeyLabel
IDL
attribute, and the Hidden
State facet is exposed by the hidden
IDL attribute.
commands
Returns an HTMLCollection
of the elements in the
Document
that define commands and have IDs.
The commands
attribute
of the document's HTMLDocument
interface must return an
HTMLCollection
rooted at the Document
node, whose filter matches only elements that define commands and have IDs.
User agents may expose the commands whose Hidden State facet is false (visible), e.g. in the user agent's menu bar. User agents are encouraged to do this especially for commands that have Access Keys, as a way to advertise those keys to the user.
a
element to define a commandAn a
element with an href
attribute defines a command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element. If the attribute is not present, the Hint is the empty string.
The Icon of the command
is the absolute URL obtained from resolving the value of the src
attribute of the first
img
element descendant of the element, relative to that
element, if there is such an element and resolving its attribute is
successful. Otherwise, there is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State facet of the command is always false. (The command is always enabled.)
The Checked State of the command is always false. (The command is never checked.)
The Action of the
command is to fire a click
event at the element.
button
element to define a commandA button
element always defines a command.
The Type, ID, Label, Hint, Icon, Access Key, Hidden State, Checked State, and Action facets of the command are
determined as for a
elements (see the previous section).
The Disabled State of the command mirrors the disabled state of the button.
input
element to define a commandAn input
element whose type
attribute is in one of the Submit Button, Reset Button, Image Button, Button, Radio Button, or Checkbox states defines a command.
The Type of the command
is "radio" if the type
attribute is in the Radio
Button
state, "checkbox" if the type
attribute is in the Checkbox
state, and
"command" otherwise.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command depends on the Type of the command:
If the Type is "command",
then it is the string given by the value
attribute, if any, and a
UA-dependent, locale-dependent value that the UA uses to label the
button itself if the attribute is absent.
Otherwise, the Type is
"radio" or "checkbox". If the element is a labeled
control, the textContent
of the first
label
element in tree order whose
labeled control is the element in question is the Label (in DOM terms, this is the
string given by element.labels[0].textContent
). Otherwise,
the value of the value
attribute, if present, is the Label. Otherwise, the Label is the empty string.
The Hint of the command
is the value of the title
attribute
of the input
element. If the attribute is not present, the
Hint is the empty
string.
If the element's type
attribute is in the Image
Button state, and the element has a src
attribute, and that attribute's
value can be successfully resolved relative to the element, then the Icon of the command is the
absolute URL obtained from resolving that attribute
that way. Otherwise, there is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State of the command mirrors the disabled state of the control.
The Checked State of the command is true if the command is of Type "radio" or "checkbox" and the element is checked attribute, and false otherwise.
The Action of the
command, if the element has a defined activation
behavior, is to run synthetic click activation
steps on the element. Otherwise, it is just to fire a
click
event at the
element.
option
element to define a commandAn option
element with an ancestor
select
element and either no value
attribute or a value
attribute that is not the
empty string defines a
command.
The Type of the command
is "radio" if the option
's nearest ancestor
select
element has no multiple
attribute, and
"checkbox" if it does.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the value of the option
element's label
attribute, if there is one,
or the value of the option
element's
textContent
IDL attribute if there isn't.
The Hint of the command
is the string given by the element's title
attribute, if any, and the empty
string if the attribute is absent.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled
State of the command is true (disabled) if the element is
disabled or if its
nearest ancestor select
element is disabled, and false
otherwise.
The Checked State of the command is true (checked) if the element's selectedness is true, and false otherwise.
The Action of the
command depends on its Type. If the command is of Type "radio" then it must pick the option
element. Otherwise, it must toggle the option
element.
command
element to define
a commandA command
element defines a command.
The Type of the command
is "radio" if the command
's type
attribute is
"radio
", "checkbox" if the attribute's value is
"checkbox
", and "command" otherwise.
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the value of the element's label
attribute, if there is one,
or the empty string if it doesn't.
The Hint of the command
is the string given by the element's title
attribute, if any, and the
empty string if the attribute is absent.
The Icon for the command
is the absolute URL obtained from resolving the value of the element's icon
attribute, relative to the
element, if it has such an attribute and resolving it is
successful. Otherwise, there is no Icon for the command.
The AccessKey of the command is the element's assigned access key, if any.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled
State of the command is true (disabled) if the element has a
disabled
attribute, and
false otherwise.
The Checked State
of the command is true (checked) if the element has a checked
attribute, and false
otherwise.
The Action of the
command, if the element has a defined activation
behavior, is to run synthetic click activation
steps on the element. Otherwise, it is just to fire a
click
event at the
element.
accesskey
attribute on a label
element to define a commandA label
element that has an assigned access
key and a labeled control and whose
labeled control defines a
command, itself defines a
command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State, Disabled State, and Action facets of the command are the same as the respective facets of the element's labeled control.
The Checked State of the command is always false. (The command is never checked.)
accesskey
attribute on a legend
element to define a commandA legend
element that has an assigned access
key and is a child of a fieldset
element that
has a descendant that is not a descendant of the legend
element and is neither a label
element nor a
legend
element but that defines a command, itself defines a command.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
is the string given by the element's textContent
IDL
attribute.
The Hint of the command
is the value of the title
attribute
of the element.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State,
Disabled State, and
Action facets of the
command are the same as the respective facets of the first element
in tree order that is a descendant of the parent of the
legend
element that defines a command but is not a
descendant of the legend
element and is neither a
label
nor a legend
element.
The Checked State of the command is always false. (The command is never checked.)
accesskey
attribute to define a command on other elementsAn element that has an assigned access key defines a command.
If one of the other sections that define elements that define commands define that this element defines a command, then that section applies to this element, and this section does not. Otherwise, this section applies to that element.
The Type of the command is "command".
The ID of the command is
the value of the id
attribute of the
element, if the attribute is present and not empty. Otherwise the
command is an anonymous command.
The Label of the command
depends on the element. If the element is a labeled
control, the textContent
of the first
label
element in tree order whose
labeled control is the element in question is the Label (in DOM terms, this is the
string given by element.labels[0].textContent
). Otherwise, the
Label is the
textContent
of the element itself.
The Hint of the command
is the value of the title
attribute
of the element. If the attribute is not present, the Hint is the empty string.
There is no Icon for the command.
The AccessKey of the command is the element's assigned access key.
The Hidden State
of the command is true (hidden) if the element has a hidden
attribute, and false
otherwise.
The Disabled State facet of the command is always false. (The command is always enabled.)
The Checked State of the command is always false. (The command is never checked.)
The Action of the command is to run the following steps:
click
event at the element.