Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

HTMLOutputElement

Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите закончить эту работу!

The HTMLOutputElement interface provides properties and methods (beyond those inherited from HTMLElement) for manipulating the layout and presentation of <output> elements.

Properties

Inherits properties from its parent, HTMLElement.

Name Type Description
defaultValue DOMString The default value of the element, initially the empty string.
formRead only HTMLFormElement Indicates the control's form owner, reflecting the form HTML attribute if it is defined.
htmlForRead only DOMSettableTokenList Reflects the for HTML attribute, containing a list of IDs of other elements in the same document that contribute to (or otherwise affect) the calculated value.
labelsRead only NodeList A list of label elements associated with this output element.
name DOMString Reflects the name HTML attribute, containing the name for the control that is submitted with form data.
type DOMString Must be the string output.
validationMessage DOMString A localized message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (willValidate is false), or it satisfies its constraints.
validityRead only ValidityState The validity states that this element is in.
value DOMString The value of the contents of the elements. Behaves like the Node.textContent property.
willValidateRead only Boolean The behavior of this property is subject to an open specification bug, as some browser maker are not happy with what is specified. It is unclear which will be the final the outcome of this.

The standard behavior is to always return false because output objects are never candidates for constraint validation.

The proposed new behavior, implemented in Firefox since Gecko 2.0 is to use this property to indicate whether the element is a candidate for constraint validation. It is false if any conditions bar it from constraint validation (See bug 604673).

Methods

Inherits methods from its parent, HTMLElement.

Name & Arguments Return Description
checkValidity() Boolean The behavior of this property is subject to an open specification bug, as some browser maker are not happy with what is specified. It is unclear which will be the final the outcome of this.

The standard behavior is to always return true because output objects are never candidates for constraint validation.

The proposed new behavior, implemented in Firefox since Gecko 2.0 is to return false if the element is a candidate for constraint validation, and it does not satisfy its constraints. In this case, it also fires an invalid event at the element. It returns true if the element is not a candidate for constraint validation, or if it satisfies its constraints (See bug 604673.).
setCustomValidity (in DOMString error) void Sets a custom validity message for the element. If this message is not the empty string, then the element is suffering from a custom validity error, and does not validate.

Modes

This element behaves in one of two modes: default mode and value mode.

Default Mode

Initially, the element is in default mode, and so the contents of the element represent both the value of the element and its default value.

If the element is in default mode when the descendants of the element are changed in any way, the defaultValue property is set to the value of the textContent property.

Resetting the form puts the element into default mode, and sets the textContent property to the value of the defaultValue property.

Value Mode

The element goes into value mode when the contents of the value property are set. The value property otherwise behaves like the textContent property. When the element is in value mode, the default value is accessible only through the defaultValue property.

Specifications

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'HTMLOutputElement' in that specification.
Living Standard No change from HTML5.
HTML5.1
The definition of 'HTMLOutputElement' in that specification.
Working Draft  
HTML5
The definition of 'HTMLOutputElement' in that specification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) 4.0 (2.0) Not supported (Yes) 5.1
labels (Yes) Not supportedbug 556743 ? ? ?
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) 4.0 (2.0) (Yes) (Yes) Not supported
labels (Yes) Not supportedbug 556743 ? ? Not supported

See also

  • The HTML element implementing this interface: <output>.

Метки документа и участники

 Внесли вклад в эту страницу: fscholz, Nexii, jwmcpeak, teoli, kscarfone, Sheppy, ethertank, Jeremie, jswisher
 Обновлялась последний раз: fscholz,