This section is normative.
The Handler Module defines elements that are used to contain information pertaining to event handler implementations, usually defined in a scripting language. Elements and attributes included in this module are:
|handler||Common, type||PCDATA | handler|
When this module is used, the handler element is added to the Structural and Text content sets of the Structural and Text Modules. In addition, the handler element is added to the content model of the head element defined in the Document Module.
Implementation: RELAX NG
The handler element places one or more event handlers within a document. This element may appear any number of times in the head or body of an XHTML document.
The handler may be defined within the contents of the handler element or in an external resource. If the src attribute is not set, user agents must interpret the contents of the element as the handler. If the src has a URI value, user agents must ignore the element's contents and retrieve the handler via the URI. Note that the encoding attribute refers to the character encoding of the handler designated by the src attribute; it does not concern the content of the handler element.
Handlers are evaluated by handler engines that must be known to a user agent.
A user agent must interpret a handler element according to the following precedence rules:
The syntax of handler data depends on the handler implementation language.
The type attribute must be specified for each handler element instance in a document.
Note that the processing model of XML means that the [DOM] method
document.write cannot be used in XHTML2. To dynamically generate
content in XHTML you have to add elements to the DOM tree using DOM calls [DOM] rather than using
document.write to generate text that
then gets parsed.
Should handler be in its own spec?XHTML 2 elements are largely semantic in nature. The handler element is a way to bind behaviors to an XHTML 2 document. As such, it should likely be done as part of the XML Events recommendation.