Elements

  • Revision slug: XBL/XBL_1.0_Reference/Elements
  • Revision title: Elements
  • Revision id: 41827
  • Created:
  • Creator: Mw22
  • Is current revision? No
  • Comment /* content */

Revision Content

bindings

<!ENTITY % bindings-content "(binding|stylesheet)*">
<!ELEMENT bindings %bindings-content;>
<!ATTLIST bindings
   id               ID           #IMPLIED
   type             CDATA        #IMPLIED
>

The bindings element is the root element of an XBL document. It contains zero or more binding elements as children. Each binding child element defines a unique binding that can be attached to elements in other documents. The bindings element can also contain script and stylesheet elements as children. These specify scripts and stylesheets that are used by the bindings.

<bindings xmlns="http://www.mozilla.org/xbl">
  <binding id="binding1">
    ...
  </binding>
  <binding id="binding2">
    ...
  </binding>
  ...
</bindings>
  • id - The id attribute is a document-unique identifier. The value of this identifier is often used to manipulate the element through a DOM interface (e.g., using document.getElementById).
  • type - The type attribute specifies the scripting language used by all bindings in the document. Bindings can selectively override this default by specifying type attributes of their own.

binding

<!ENTITY % binding-content "(content?,implementation?,handlers?)">
<!ELEMENT binding %binding-content;>
<!ATTLIST binding
   id                     ID             #REQUIRED
   extends                CDATA          #IMPLIED
   display                CDATA          #IMPLIED
   inheritstyle           true           #IMPLIED
>
  • id - The id attribute is a document-unique identifier. For the binding element, this attribute is required, since it is used to uniquely identify a binding.
  • extends - The extends attribute is used to specify the URL of a binding that this binding inherits from. The URL specifies a particular binding document. The # notation must be used to point to a specific binding id within a binding document.
  • display - This attribute specifies how the tag is displayed. By setting this attribute, you can have an element have the layout and display characteristics of an existing element. For example, use the value 'xul:button' to create an element that is displayed like a button. The part before the colon is a namespace prefix so you must declare the XUL namespace as well. Not all tags have a unique display type. The following XUL display types may be used: browser, button, checkbox, description, editor, grippy, iframe, image, label, menu, menuitem, menubar, progressmeter, radio, resizer, scrollbar, scrollbox, spacer, splitter, titlebar, treechildren and treecol. You may also use a number of HTML, MathML and SVG tags. The 'display' attribute does not work unless the extends attribute is set, see bug {{template.Bug(119389)}}. In that case, put the value of the display attribute into the extends attribute.
  • inheritstyle - The inheritstyle attribute indicates whether style rules from the document will affect anonymous content generated by the XBL binding. If this attribute is true, styles from the document will also be applied to the XBL generated anonymous content.

The binding element describes a single XBL binding that dynamically binds new information to XML elements in other documents. Each binding has three optional components.

  • content - A binding can specify new content that is placed inside the bound element. This content is anonymous and is hidden from the normal DOM. To access anonymous nodes on an XBL bound element, you can use the getAnonymousElementByAttribute and getAnonymousNodes functions.
  • Methods and Properties - A binding can specify additional methods that can be invoked on the element. It can also specify additional properties that can be retrieved or set on the element. In this way the functionality of the bound element becomes extensible.
  • Event handlers - A binding can specify event handlers for specific actions like key and mouse events that can make use of the new functionality applied in the binding.

A binding element may contain an content tag, an implementation tag, a handlers tag and a resources tag.

content

<!ELEMENT content ANY>
<!ATTLIST content
   id               ID           #IMPLIED
>

A binding can specify new content that is placed inside the bound element. Although you can see this content on screen as if it was directly in the file, this content is anonymous and is hidden from the normal DOM. To access anonymous nodes on an XBL bound element, you can use the getAnonymousElementByAttribute and getAnonymousNodes functions. The only XBL element that can appear inside the content tag is the children tag.

  • id - The id attribute is a document-unique identifier.

children

<!ELEMENT children EMPTY>
<!ATTLIST children
   id               ID                           #IMPLIED
   includes         CDATA                        #IMPLIED
>

The children element is used inside anonymous content to specify insertion points for explicit content that might already exist underneath the bound element or for anonymous content generated by the base binding. As far as the presentation model is concerned, any anonymous content the binding places between the bound element and the insertion point is interleaved between the bound element and its explicit children without affecting the document model.

See section 4.4 for more information.

  • id - The id attribute is a document-unique identifier.
  • includes - The includes attribute can be used to indicate that only certain content should be placed at the insertion point specified by the children element. It's value can be a tagname or multiple tagnames separated by comma's. A child can only be placed within the insertion point if it is matched by the value in the includes attribute. Only immediate children are matched against the selector.

implementation

<!ENTITY % implementation-content "(method|property)*">
<!ELEMENT implementation %implementation-content;>
<!ATTLIST implementation
   id               ID           #IMPLIED
   name             CDATA        #IMPLIED
   implements       CDATA        #IMPLIED
>

The implementation element describes a set of methods and properties that are attached to the bound element. Once the binding is attached, these methods and properties can be invoked directly from the bound element.

  • id - The id attribute is a document-unique identifier.
  • name - The name attribute can be used to provide a specific name for an implementation. This name can then be used to reference the implementation. For example, in Javascript the value of this attribute represents the name of the corresponding class that is constructed for the implementation. If no name attribute is specified then the binding's document URI and id are used to uniquely reference the binding's implementation.
  • implements - The implements attribute can be used to describe a set of interfaces that are implemented by the binding. Its value is a comma-separated list of named interfaces. If supported, in strongly typed languages the bound element can be referenced not only as any of the interfaces that the element might already support (e.g., HTMLElement) but also as any of the interfaces described by this attribute. Support of this capability is optional.

constructor

The code inside the constructor is called when a binding has just been attached to an element. So full access to anonymous nodes generated by the binding is already possible. The constructor tag must be placed inside the implementation tag.

  • id - The id attribute is a document-unique identifier.
  • action - The code inside theaction attribute is executed. Alternatively, you can put the code inside the constructor element itself.

destructor

The code inside the destructor is called when a binding is being removed from an element. You can use this to unload resources to free memory. However the destructor is often not called when it should, see {{template.Bug(230086)}}. The destructor tag must be placed inside the implementation tag.

  • id - The id attribute is a document-unique identifier.
  • action - The code inside theaction attribute is executed. Alternatively, you can put the code inside the destructor element itself.

method

<!ENTITY % method-content "(parameter*,body?)">
<!ELEMENT method %method-content;>
<!ATTLIST method
   id               ID           #IMPLIED
   name             CDATA        #REQUIRED
   type             CDATA        #IMPLIED
>

The method element is used to describe a single method of a binding implementation.

  • id - The id attribute is a document-unique identifier.
  • name - The name attribute's value is the name given to the method when it is attached to the bound element. The method can be invoked directly from the bound element using this value.

Example

<method name="scrollTo">
  <parameter name="index"/>
  <body>
    this.setAttribute("scrollpos", index);
  </body>
</method>

parameter

<!ELEMENT parameter EMPTY>
<!ATTLIST parameter
   id               ID           #IMPLIED
   name             CDATA        #REQUIRED
>

The parameter element is used inside a method element. It represents a single parameter of a method.

  • id - The id attribute is a document-unique identifier.
  • name - The value of the name attribute is used by script within a method's body element to reference this parameter.

body

<!ELEMENT body CDATA>
<!ATTLIST body
   id               ID           #IMPLIED
>

The body element represents the implementation of its corresponding method. Its contents are the script that is executed when the method is invoked.

  • id - The id attribute is a document-unique identifier.

field

A field is similar to a property, except that it should not have a getter or setter. It is useful as a simple holder for a value. The field element may have content which is code that determines the initial value of the field. The field tag must be inside the implementation tag.

  • id - The id attribute is a document-unique identifier.
  • name - The name of the field. This is the name used to refer to the field on the bound element.

property

<!ENTITY % property-content "(getter?,setter?)|#PCDATA">
<!ELEMENT property %property-content;>
<!ATTLIST property
   id               ID                  #IMPLIED
   name             CDATA               #REQUIRED
   readonly         (true|false)        #IMPLIED
   onget            CDATA               #IMPLIED
   onset            CDATA               #IMPLIED
>

The property element represents a single property of an implementation. A property consists of a pair of getter/setter functions that can be defined using onget/onset attributes or getter/setter elements underneath the property element. Like methods, once the binding is attached, the property can be obtained directly from the bound element. The property tag must be inside the implementation tag.

  • id - The id attribute is a document-unique identifier.
  • name - The name of the property. This is the name used to refer to the property on the bound element.
  • readonly - The readonly attribute is used to designate a property as read-only. If set to true, the value of the property cannot be altered. If this attribute is omitted, the property will be readable and writable.
  • onget - The onget attribute's value is a script that executes when the value of the property is requested. If this attribute is set, any initial value contained underneath the element will be ignored. The return value of the script represents the value of the property that will be returned to the requestor. A property getter can also be specified as a child of the property element using the getter tag.
  • onset - The onset attribute's value is a script that executes when the value of the property is being altered. If this attribute is set, any initial value contained underneath the element will be ignored. Within the script, the parameter val represents the new value being assigned. The script should always return the actual value assigned in order to allow for chained assignment operations. A property setter can also be specified as a child of the property element using a setter tag.

getter

<!ELEMENT getter PCDATA>
<!ATTLIST getter
   id               ID                  #IMPLIED
>

The getter element contains script that gets executed when a specific property gets called. The getter tag must be inside the property tag.

  • id - The id attribute is a document-unique identifier.

setter

<!ELEMENT setter PCDATA>
<!ATTLIST setter
   id               ID                  #IMPLIED
>

The setter element contains script that gets executed when a specific property is being set. The setter tag must be inside the property tag.

  • id - The id attribute is a document-unique identifier.

handlers

<!ENTITY % handlers-content "handler*">
<!ELEMENT handlers %handlers-content;>
<!ATTLIST handlers
   id               ID                  #IMPLIED
>

The handlers element contains event handlers that can be attached to elements within the bound document. These handlers are installed when the binding is attached and removed when the binding is detached. The handlers tag must be inside the binding tag.

  • id - The id attribute is a document-unique identifier.

handler

<!ENTITY % handler-content "PCDATA">
<!ELEMENT handler %handler-content;>
<!ATTLIST handler
   id               ID                                  #IMPLIED
   event            NMREF                               #REQUIRED
   action           CDATA                               #IMPLIED
   phase            (capturing|bubbling|target)         #IMPLIED
   attachto         (element|document|window)           element
   button           (1|2|3)                             #IMPLIED
   modifiers        CDATA                               #IMPLIED
   keycode          CDATA                               #IMPLIED
   charcode         CDATA                               #IMPLIED
   clickcount       (1|2|3)                             #IMPLIED
   command          ID                                  #IMPLIED
   preventdefault   false|true                          #IMPLIED
>

The handler element describes a single event handler. This handler is attached to its target at the time the binding is attached and unhooked when the binding is detached from the bound element. The script inside the handler is executed when the event handler is matched. The handler tag must be inside the handlers tag.

  • id - The id attribute is a document-unique identifier.
  • event - The event attribute describes the specific event that this handler is listening for. Its value can be any legal DOM event name (including custom events created using the DocumentEvent interface of the DOM).
  • action - The action attribute contains script that is invoked when the handler fires. The type attribute on the enclosing handlers element determines the language of the script. The handler script can also be specified as a child of the handler element.
  • phase - This attribute specifies the phase of the event flow that this handler should monitor. The possible values are capturing, bubbling, and target. If a phase is specified, the handler will only be invoked during that phase of the event handling process. If no phase is specified, a default of bubbling is assumed.
  • attachto - The attachto attribute specifies the DOM event receiver that the handler should be registered with. Possible values are element, document, and window. A value of element indicates that the handler should be attached to the bound element. A value of document specifies the bound document as a target. A value of window represents the window that encloses the bound document. If this attribute is omitted, the handler attaches itself to the bound element.
    {{mediawiki.external('Editor\'s Note: Should window be mentioned in the spec? The DOM makes no mention of windows.')}}
  • button - The button attribute imposes a filter on the handler. It is used with mouse handlers to specify a particular button. The event handler will only be matched if the value of the button field in the DOM mouse event object matches the value of the attribute.
  • modifiers - The modifiers attribute imposes a filter on key and mouse handlers. Its value is a comma-separated list of modifier keys. Allowed keys that can be specified are shift, alt, control, meta, accel and accesskey. If present in the list, then the modifier key must be set in the DOM event object in order for the handler to be matched. If the handler is filtered and the modifier is not present in the list, then the modifier key must not be set in the DOM event object in order for the handler to be matched. The accel value provides a hint to the user agent that the platform's primary accelerator key should be used. It is left up to the user agent to decide which modifier key represents the primary key. The accesskey value provides a hint to the user agent that the platform's primary shortcut mnemonic key should be used.
  • keycode - The keycode attribute imposes a filter on key handlers. Its value is a key identifier for a specific keycode, e.g., vk_enter.
    {{mediawiki.external('Editor\'s Note: A forthcoming DOM events specification will presumably outline the list of valid keycode strings.')}}
    If this attribute is present, then its value must match the keycode field of the DOM key event object in order for the handler to fire.
  • charcode - The charcode attribute imposes a filter on key handlers. Its value is a single character, e.g., "z". If this attribute is present, then its value must match the charcode field of the DOM key event object in order for the handler to fire.
    {{mediawiki.external('Editor\'s Note: As DOM Events mature more attributes may be added. For example, mutation events define several new fields such as relatedTarget that could be supported in the filtering syntax.')}}
  • clickcount - The clickcount attribute imposes a filter on the handler. It is used with mouse handlers to specify how many times a button has been clicked. The event handler will only be matched if the value of the clickcount field in the DOM mouse event object matches the value of the attribute.
  • command - The id of a command to invoke when the event occurs. If used in a non-chrome document, the entire handler will be ignored.
  • preventdefault - If set to true, the default action of the event is not performed.

resources

<!ENTITY % resources-content "(image?,stylesheet?)">
<!ELEMENT resources %resources-content;>
<!ATTLIST property
   id               ID                  #IMPLIED
>

Used for inclusion of image elements, to cache them for later use, and for inclusion of stylesheet elements. The resources tag must be used directly inside the binding tag.

  • id - The id attribute is a document-unique identifier.

stylesheet

<!ELEMENT stylesheet EMPTY>
<!ATTLIST stylesheet
   id               ID                  #IMPLIED
   src              URI                 #REQUIRED
>

The stylesheet element declares a style sheet used by the binding. Using this element is preferred over using an XML processing instruction. The style rules in the style sheet will only be applied to the binding, not to other elements in the document. The stylesheet tag must be inside the resources tag.

  • id - The id attribute is a document-unique identifier.
  • src - The URL of the style sheet to apply to the binding content.

image

<!ELEMENT image EMPTY>
<!ATTLIST image
   id               ID                  #IMPLIED
   src              URI                 #REQUIRED
>

Declares an image resource used by the binding. The image is loaded as soon as the binding is used. You can use this to preload a number of images for later use. The image tag must be inside the resources tag.

  • id - The id attribute is a document-unique identifier.
  • src - The URL of the image to load.

Revision Source

<p>
</p>
<h2 name="bindings">bindings</h2>
<pre>&lt;!ENTITY % bindings-content "(binding|stylesheet)*"&gt;
&lt;!ELEMENT bindings %bindings-content;&gt;
&lt;!ATTLIST bindings
   id               ID           #IMPLIED
   type             CDATA        #IMPLIED
&gt;
</pre>
<p>The <code>bindings</code> element is the root element of an XBL document. It contains zero or more <code>binding</code> elements as children. Each <code>binding</code> child element defines a unique binding that can be attached to elements in other documents. The <code>bindings</code> element can also contain <code>script</code> and <code>stylesheet</code> elements as children. These specify scripts and stylesheets that are used by the bindings.
</p>
<pre>&lt;bindings xmlns="http://www.mozilla.org/xbl"&gt;
  &lt;binding id="binding1"&gt;
    ...
  &lt;/binding&gt;
  &lt;binding id="binding2"&gt;
    ...
  &lt;/binding&gt;
  ...
&lt;/bindings&gt;
</pre>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. The value of this identifier is often used to manipulate the element through a DOM interface (e.g., using <code>document.getElementById</code>). 
</li><li> <code><b>type</b></code> - The <code>type</code> attribute specifies the scripting language used by all bindings in the document. Bindings can selectively override this default by specifying <code>type</code> attributes of their own.
</li></ul>
<h2 name="binding">binding</h2>
<pre>&lt;!ENTITY % binding-content "(content?,implementation?,handlers?)"&gt;
&lt;!ELEMENT binding %binding-content;&gt;
&lt;!ATTLIST binding
   id                     ID             #REQUIRED
   extends                CDATA          #IMPLIED
   display                CDATA          #IMPLIED
   inheritstyle           true           #IMPLIED
&gt;
</pre>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. For the binding element, this attribute is required, since it is used to uniquely identify a binding. 
</li><li> <code><b>extends</b></code> - The <code>extends</code> attribute is used to specify the URL of a binding that this binding inherits from. The URL specifies a particular binding document. The # notation must be used to point to a specific binding <code>id</code> within a binding document.
</li><li> <code><b>display</b></code> - This attribute specifies how the tag is displayed. By setting this attribute, you can have an element have the layout and display characteristics of an existing element. For example, use the value 'xul:button' to create an element that is displayed like a button. The part before the colon is a namespace prefix so you must declare the XUL namespace as well. Not all tags have a unique display type. The following XUL display types may be used: browser, button, checkbox, description, editor, grippy, iframe, image, label, menu, menuitem, menubar, progressmeter, radio, resizer, scrollbar, scrollbox, spacer, splitter, titlebar, treechildren and treecol. You may also use a number of HTML, MathML and SVG tags. The 'display' attribute does not work unless the <code>extends</code> attribute is set, see bug {{template.Bug(119389)}}. In that case, put the value of the <code>display</code> attribute into the <code>extends</code> attribute.
</li><li> <code><b>inheritstyle</b></code> - The <code>inheritstyle</code> attribute indicates whether style rules from the document will affect anonymous content generated by the XBL binding. If this attribute is true, styles from the document will also be applied to the XBL generated anonymous content.
</li></ul>
<p>The <code>binding</code> element describes a single XBL binding that dynamically binds new information to XML elements in other documents. Each binding has three optional components.
</p>
<ul><li> <i><a href="en/XBL/XBL_1.0_Reference/Elements#_content">content</a></i> - A binding can specify new content that is placed inside the bound element. This content is anonymous and is hidden from the normal <a href="en/DOM">DOM</a>. To access anonymous nodes on an XBL bound element, you can use the <a href="en/XBL/XBL_1.0_Reference/DOM_Interfaces#getAnonymousElementByAttribute">getAnonymousElementByAttribute</a> and <a href="en/XBL/XBL_1.0_Reference/DOM_Interfaces#getAnonymousNodes">getAnonymousNodes</a> functions. 
</li><li> <i><a href="en/XBL/XBL_1.0_Reference/Elements#method">Methods</a> and <a href="en/XBL/XBL_1.0_Reference/Elements#property">Properties</a></i> - A binding can specify additional methods that can be invoked on the element. It can also specify additional properties that can be retrieved or set on the element. In this way the functionality of the bound element becomes extensible.
</li><li> <i><a href="en/XBL/XBL_1.0_Reference/Elements#handlers">Event handlers</a></i> - A binding can specify event handlers for specific actions like key and mouse events that can make use of the new functionality applied in the binding.
</li></ul>
<p>A binding element may contain an <a href="en/XBL/XBL_1.0_Reference/Elements#_content">content</a> tag, an <a href="en/XBL/XBL_1.0_Reference/Elements#implementation">implementation</a> tag, a <a href="en/XBL/XBL_1.0_Reference/Elements#handlers">handlers</a> tag and a <a href="en/XBL/XBL_1.0_Reference/Elements#handlers">resources</a> tag.
</p><p><span id="_content"></span>
</p>
<h2 name="content"> content</h2>
<pre>&lt;!ELEMENT content ANY&gt;
&lt;!ATTLIST content
   id               ID           #IMPLIED
&gt;
</pre>
<p>A binding can specify new content that is placed inside the bound element.  Although you can see this content on screen as if it was directly in the file, this content is anonymous and is hidden from the normal <a href="en/DOM">DOM</a>. To access anonymous nodes on an XBL bound element, you can use the <a href="en/XBL/XBL_1.0_Reference/DOM_Interfaces#getAnonymousElementByAttribute">getAnonymousElementByAttribute</a> and <a href="en/XBL/XBL_1.0_Reference/DOM_Interfaces#getAnonymousNodes">getAnonymousNodes</a> functions.
The only XBL element that can appear inside the content tag is the <a href="en/XBL/XBL_1.0_Reference/Elements#children">children</a> tag.
</p>
<ul><li> <code><b>id</b></code> - The id attribute is a document-unique identifier.
</li></ul>
<h2 name="children">children</h2>
<pre>&lt;!ELEMENT children EMPTY&gt;
&lt;!ATTLIST children
   id               ID                           #IMPLIED
   includes         CDATA                        #IMPLIED
&gt;
</pre>
<p>The <code>children</code> element is used inside anonymous content to specify insertion points for explicit content that might already exist underneath the bound element or for anonymous content generated by the base binding. As far as the presentation model is concerned, any anonymous content the binding places between the bound element and the insertion point is interleaved between the bound element and its explicit children without affecting the document model.
</p><p>See <a href="en/Section_4.4">section 4.4</a> for more information.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>includes</b></code> - The <code>includes</code> attribute can be used to indicate that only certain content should be placed at the insertion point specified by the <code>children</code> element. It's value can be a tagname or multiple tagnames separated by comma's. A child can only be placed within the insertion point if it is matched by the value in the <code>includes</code> attribute. Only immediate children are matched against the selector.
</li></ul>
<h2 name="implementation">implementation</h2>
<pre>&lt;!ENTITY % implementation-content "(method|property)*"&gt;
&lt;!ELEMENT implementation %implementation-content;&gt;
&lt;!ATTLIST implementation
   id               ID           #IMPLIED
   name             CDATA        #IMPLIED
   implements       CDATA        #IMPLIED
&gt;
</pre>
<p>The <code>implementation</code> element describes a set of methods and properties that are attached to the bound element. Once the binding is attached, these methods and properties can be invoked directly from the bound element.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The <code>name</code> attribute can be used to provide a specific name for an implementation. This name can then be used to reference the implementation. For example, in Javascript the value of this attribute represents the name of the corresponding class that is constructed for the implementation. If no name attribute is specified then the binding's document URI and id are used to uniquely reference the binding's implementation. 
</li><li> <code><b>implements</b></code> - The <code>implements</code> attribute can be used to describe a set of interfaces that are implemented by the binding. Its value is a comma-separated list of named interfaces. If supported, in strongly typed languages the bound element can be referenced not only as any of the interfaces that the element might already support (e.g., HTMLElement) but also as any of the interfaces described by this attribute. Support of this capability is optional.
</li></ul>
<h2 name="constructor">constructor</h2>
<p>The code inside the <code>constructor</code> is called when a <code>binding</code> has just been attached to an element. So full access to anonymous nodes generated by the binding is already possible. The <code>constructor</code> tag must be placed inside the <code>implementation</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li><li> <code><b>action</b></code> - The code inside the<code>action</code> attribute is executed. Alternatively, you can put the code inside the <code>constructor</code> element itself.
</li></ul>
<h2 name="destructor">destructor</h2>
<p>The code inside the <code>destructor</code> is called when a <code>binding</code> is being removed from an element. You can use this to unload resources to free memory. However the <code>destructor</code> is often not called when it should, see {{template.Bug(230086)}}. The <code>destructor</code> tag must be placed inside the <code>implementation</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li><li> <code><b>action</b></code> - The code inside the<code>action</code> attribute is executed. Alternatively, you can put the code inside the <code>destructor</code> element itself.
</li></ul>
<h2 name="method">method</h2>
<pre>&lt;!ENTITY % method-content "(parameter*,body?)"&gt;
&lt;!ELEMENT method %method-content;&gt;
&lt;!ATTLIST method
   id               ID           #IMPLIED
   name             CDATA        #REQUIRED
   type             CDATA        #IMPLIED
&gt;
</pre>
<p>The <code>method</code> element is used to describe a single method of a binding implementation.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The <code>name</code> attribute's value is the name given to the method when it is attached to the bound element. The method can be invoked directly from the bound element using this value. 
</li></ul>
<p><i>Example</i>
</p>
<pre>&lt;method name="scrollTo"&gt;
  &lt;parameter name="index"/&gt;
  &lt;body&gt;
    this.setAttribute("scrollpos", index);
  &lt;/body&gt;
&lt;/method&gt;
</pre>
<h2 name="parameter">parameter</h2>
<pre>&lt;!ELEMENT parameter EMPTY&gt;
&lt;!ATTLIST parameter
   id               ID           #IMPLIED
   name             CDATA        #REQUIRED
&gt;
</pre>
<p>The <code>parameter</code> element is used inside a <code>method</code> element. It represents a single parameter of a method.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The value of the <code>name</code> attribute is used by script within a method's <code>body</code> element to reference this parameter.
</li></ul>
<h2 name="body">body</h2>
<pre>&lt;!ELEMENT body CDATA&gt;
&lt;!ATTLIST body
   id               ID           #IMPLIED
&gt;
</pre>
<p>The <code>body</code> element represents the implementation of its corresponding <code>method</code>. Its contents are the script that is executed when the method is invoked.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li></ul>
<h2 name="field">field</h2>
<p>A field is similar to a <code><a href="en/XBL/XBL_1.0_Reference/Elements#property">property</a></code>, except that it should not have a getter or setter. It is useful as a simple holder for a value. The field element may have content which is code that determines the initial value of the field. The <code>field</code> tag must be inside the <code>implementation</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The name of the field. This is the name used to refer to the field on the bound element. 
</li></ul>
<h2 name="property">property</h2>
<pre>&lt;!ENTITY % property-content "(getter?,setter?)|#PCDATA"&gt;
&lt;!ELEMENT property %property-content;&gt;
&lt;!ATTLIST property
   id               ID                  #IMPLIED
   name             CDATA               #REQUIRED
   readonly         (true|false)        #IMPLIED
   onget            CDATA               #IMPLIED
   onset            CDATA               #IMPLIED
&gt;
</pre>
<p>The <code>property</code> element represents a single property of an implementation. A property consists of a pair of getter/setter functions that can be defined using <code>onget</code>/<code>onset</code> attributes or <a href="en/XBL/XBL_1.0_Reference/Elements#getter">getter</a>/<a href="en/XBL/XBL_1.0_Reference/Elements#setter">setter</a> elements underneath the <code>property</code> element. Like methods, once the binding is attached, the property can be obtained directly from the bound element.
The <code>property</code> tag must be inside the <code>implementation</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>name</b></code> - The name of the property. This is the name used to refer to the property on the bound element.
</li><li> <code><b>readonly</b></code> - The <code>readonly</code> attribute is used to designate a property as read-only. If set to <code>true</code>, the value of the property cannot be altered. If this attribute is omitted, the property will be readable and writable. 
</li><li> <code><b>onget</b></code> - The <code>onget</code> attribute's value is a script that executes when the value of the property is requested. If this attribute is set, any initial value contained underneath the element will be ignored. The return value of the script represents the value of the property that will be returned to the requestor. A property getter can also be specified as a child of the <code>property</code> element using the <code>getter</code> tag. 
</li><li> <code><b>onset</b></code> - The <code>onset</code> attribute's value is a script that executes when the value of the property is being altered. If this attribute is set, any initial value contained underneath the element will be ignored. Within the script, the parameter <code>val</code> represents the new value being assigned. The script should always return the actual value assigned in order to allow for chained assignment operations. A property setter can also be specified as a child of the <code>property</code> element using a <code>setter</code> tag.
</li></ul>
<h2 name="getter">getter</h2>
<pre>&lt;!ELEMENT getter PCDATA&gt;
&lt;!ATTLIST getter
   id               ID                  #IMPLIED
&gt;
</pre>
<p>The <code>getter</code> element contains script that gets executed when a specific property gets called. The <code>getter</code> tag must be inside the <code>property</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li></ul>
<h2 name="setter">setter</h2>
<pre>&lt;!ELEMENT setter PCDATA&gt;
&lt;!ATTLIST setter
   id               ID                  #IMPLIED
&gt;
</pre>
<p>The <code>setter</code> element contains script that gets executed when a specific property is being set. The <code>setter</code> tag must be inside the <code>property</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li></ul>
<h2 name="handlers">handlers</h2>
<pre>&lt;!ENTITY % handlers-content "handler*"&gt;
&lt;!ELEMENT handlers %handlers-content;&gt;
&lt;!ATTLIST handlers
   id               ID                  #IMPLIED
&gt;
</pre>
<p>The <code>handlers</code> element contains event handlers that can be attached to elements within the bound document. These handlers are installed when the binding is attached and removed when the binding is detached. The <code>handlers</code> tag must be inside the <code>binding</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li></ul>
<h2 name="handler">handler</h2>
<pre>&lt;!ENTITY % handler-content "PCDATA"&gt;
&lt;!ELEMENT handler %handler-content;&gt;
&lt;!ATTLIST handler
   id               ID                                  #IMPLIED
   event            NMREF                               #REQUIRED
   action           CDATA                               #IMPLIED
   phase            (capturing|bubbling|target)         #IMPLIED
   attachto         (element|document|window)           element
   button           (1|2|3)                             #IMPLIED
   modifiers        CDATA                               #IMPLIED
   keycode          CDATA                               #IMPLIED
   charcode         CDATA                               #IMPLIED
   clickcount       (1|2|3)                             #IMPLIED
   command          ID                                  #IMPLIED
   preventdefault   false|true                          #IMPLIED
&gt;
</pre>
<p>The <code>handler</code> element describes a single event handler. This handler is attached to its target at the time the binding is attached and unhooked when the binding is detached from the bound element. The script inside the <code>handler</code> is executed when the event handler is matched. The <code>handler</code> tag must be inside the <code>handlers</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier. 
</li><li> <code><b>event</b></code> - The <code>event</code> attribute describes the specific event that this handler is listening for. Its value can be any legal DOM event name (including custom events created using the DocumentEvent interface of the DOM).
</li><li> <code><b>action</b></code> - The <code>action</code> attribute contains script that is invoked when the handler fires. The <code>type</code> attribute on the enclosing <code>handlers</code> element determines the language of the script. The handler script can also be specified as a child of the <code>handler</code> element. 
</li><li> <code><b>phase</b></code> - This attribute specifies the phase of the event flow that this handler should monitor. The possible values are <code>capturing</code>, <code>bubbling</code>, and <code>target</code>. If a phase is specified, the handler will only be invoked during that phase of the event handling process. If no phase is specified, a default of <code>bubbling</code> is assumed. 
</li><li> <code><b>attachto</b></code> - The <code>attachto</code> attribute specifies the DOM event receiver that the handler should be registered with. Possible values are <code>element</code>, <code>document</code>, and <code>window</code>. A value of <code>element</code> indicates that the handler should be attached to the bound element. A value of <code>document</code> specifies the bound document as a target. A value of <code>window</code> represents the window that encloses the bound document. If this attribute is omitted, the handler attaches itself to the bound element.<br> {{mediawiki.external('Editor\'s Note: Should window be mentioned in the spec? The DOM makes no mention of windows.')}} 
</li><li> <code><b>button</b></code> - The <code>button</code> attribute imposes a <i>filter</i> on the handler. It is used with mouse handlers to specify a particular button. The event handler will only be matched if the value of the <code>button</code> field in the DOM mouse event object matches the value of the attribute. 
</li><li> <code><b>modifiers</b></code> - The <code>modifiers</code> attribute imposes a filter on key and mouse handlers. Its value is a comma-separated list of modifier keys. Allowed keys that can be specified are <code>shift</code>, <code>alt</code>, <code>control</code>, <code>meta</code>, <code>accel</code> and <code>accesskey</code>. If present in the list, then the modifier key must be set in the DOM event object in order for the handler to be matched. If the handler is filtered and the modifier is not present in the list, then the modifier key must not be set in the DOM event object in order for the handler to be matched. The <code>accel</code> value provides a hint to the user agent that the platform's primary accelerator key should be used. It is left up to the user agent to decide which modifier key represents the primary key. The <code>accesskey</code> value provides a hint to the user agent that the platform's primary shortcut mnemonic key should be used. 
</li><li> <code><b>keycode</b></code> - The <code>keycode</code> attribute imposes a filter on key handlers. Its value is a key identifier for a specific keycode, e.g., <code>vk_enter</code>.<br> {{mediawiki.external('Editor\'s Note: A forthcoming DOM events specification will presumably outline the list of valid keycode strings.')}}<br> If this attribute is present, then its value must match the <code>keycode</code> field of the DOM key event object in order for the handler to fire. 
</li><li> <code><b>charcode</b></code> - The <code>charcode</code> attribute imposes a filter on key handlers. Its value is a single character, e.g., "<code>z</code>". If this attribute is present, then its value must match the <code>charcode</code> field of the DOM key event object in order for the handler to fire.<br> {{mediawiki.external('Editor\'s Note: As DOM Events mature more attributes may be added. For example, mutation events define several new fields such as relatedTarget that could be supported in the filtering syntax.')}} 
</li><li> <code><b>clickcount</b></code> - The <code>clickcount</code> attribute imposes a <i>filter</i> on the handler. It is used with mouse handlers to specify how many times a button has been clicked. The event handler will only be matched if the value of the <code>clickcount</code> field in the DOM mouse event object matches the value of the attribute.
</li><li> <code><b>command</b></code> - The id of a command to invoke when the event occurs. If used in a non-chrome document, the entire handler will be ignored.
</li><li> <code><b>preventdefault</b></code> - If set to true, the default action of the event is not performed.
</li></ul>
<h2 name="resources">resources</h2>
<pre>&lt;!ENTITY % resources-content "(image?,stylesheet?)"&gt;
&lt;!ELEMENT resources %resources-content;&gt;
&lt;!ATTLIST property
   id               ID                  #IMPLIED
&gt;
</pre>
<p>Used for inclusion of <a href="en/XBL/XBL_1.0_Reference#image">image</a> elements, to cache them for later use, and for inclusion of <a href="en/XBL/XBL_1.0_Reference#stylesheet">stylesheet</a> elements.
The <code>resources</code> tag must be used directly inside the <code>binding</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li></ul>
<h2 name="stylesheet">stylesheet</h2>
<pre>&lt;!ELEMENT stylesheet EMPTY&gt;
&lt;!ATTLIST stylesheet
   id               ID                  #IMPLIED
   src              URI                 #REQUIRED
&gt;
</pre>
<p>The <code>stylesheet</code> element declares a style sheet used by the binding. Using this element is preferred over using an XML processing instruction. The style rules in the style sheet will only be applied to the binding, not to other elements in the document. The <code>stylesheet</code> tag must be inside the <code>resources</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li><li> <code><b>src</b></code> - The URL of the style sheet to apply to the binding content.
</li></ul>
<h2 name="image">image</h2>
<pre>&lt;!ELEMENT image EMPTY&gt;
&lt;!ATTLIST image
   id               ID                  #IMPLIED
   src              URI                 #REQUIRED
&gt;
</pre>
<p>Declares an image resource used by the binding. The image is loaded as soon as the binding is used. You can use this to preload a number of images for later use.  The <code>image</code> tag must be inside the <code>resources</code> tag.
</p>
<ul><li> <code><b>id</b></code> - The <code>id</code> attribute is a document-unique identifier.
</li><li> <code><b>src</b></code> - The URL of the image to load.
</li></ul>
Revert to this revision