dean.edwards.name/moz-behaviors/usage/

Usage

Behavior Files (.htc)

for a start, you can read these documents from Microsoft:

the following bullet points represent rules rather than suggestions:

*not sure this is true actually.

Attaching with CSS

Reference behaviors in the following manner in your style sheet:

div.drag-box {
	/* reference behaviors in the usual way for explorer */
	behavior: url(drag-box.htc);
	/* reference behaviors like this for mozilla */
	-moz-binding: url(bindings.xml#drag-box.htc);
}

Multiple bindings:

pre.html {
	/* for explorer */
	behavior: url(/my/star-html.htc) url(/my/star-light.htc);
	/* and for mozilla */
	-moz-binding: url(/my/bindings.xml#star-html.htc|star-light.htc);
}

Ensure that the file bindings.xml resides in the same directory as your behavior file(s).

Note: any kind of CSS error in your style setting will cause the behavior not to load. It may also result in the element not rendering correctly.

Attaching with JavaScript

Mozilla’s Element interface has been extended to include the addBehavior and removeBehavior* methods:

var image = document.getElementById("ticker");
image.addBehavior("ticker.htc");

* removeBehavior has not yet been implemented.

bindings.xml

The binding file bindings.xml should reside in the same directory as the behavior file(s) you wish to reference. It is not possible to reference behaviors scattered across several directories from the same binding (although it is possible to access multiple bindings from the same style sheet).

Point bindings.xml to moz-behaviors.xml. Usually this is the same directory:

<!-- provide the default path to moz-behaviors.xml
       (keep the #behavior suffix) -->
<binding id="behavior" extends="moz-behaviors.xml#behavior"/>

Update bindings.xml for each behavior you wish to reference:

<!-- reference to a dhtml behavior -->
<binding id="drag-box.htc" extends="#behavior"/>

<!-- multiple bindings -->
<binding id="star-html.htc|star-light.htc" extends="#behavior"/>

you do not need to make any other alterations to this file.

Cross-browser Considerations

When writing behaviors, use W3C specified DOM API and ECMAScript standards. Avoid proprietary Microsoft properties and methods:

var element = document.getElementById("element1");

View the compatibility table for more information.

Trouble-shooting

Microsoft Internet Explorer is a very forgiving browser. You can type any old junk into it and it’ll render what it can. The point is, if your behavior works in Explorer but doesn’t in Mozilla, don’t despair!

Feedback

To ensure the quality of this software, please feedback comments, suggestions, bug reports etc, to the author.