element Object
Returns a reference to the tag in the primary document to which the behavior is attached.
Members Table
The following table lists the members exposed by the element object.
Property Description defaults Retrieves a dispatch representing a default. document Retrieves a dispatch representing a document. element Retrieves an element. name Retrieves a behavior name as a string. urn Retrieves a Uniform Resource Name (URN) as a string. value Sets or retrieves a value.
Method Description createEventObject Creates an event object that can be used to pass event context information to the PUBLIC:EVENT element's fire method. fire Fires the event, given an event object. fireChange Notifies the containing document that the value of the property has changed by firing the onpropertychange event on the element.
Object Description Element Constructor Defines the properties and methods inherited by objects in the Element Constructor prototype chain.
Remarks
All properties, methods, and events of the element to which the behavior is attached are accessible to HTML Component (HTC) using this object. The element object is the default object of properties, methods, or event names specified in the HTC. Therefore, they can be specified directly, without using the element keyword.
Example
This example uses a behavior to implement a table of contents that expands and collapses when the user clicks it. The HTC attaches to the element's onmouseover event and sets the color property of the element to red. The color of the element can be toggled through the style object directly, instead of referring to it as element.style. The HTC also sets the cursor property to "
hand
" to signal the user that the element can be clicked to toggle visibility of its children.<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="Hilite" /> <SCRIPT LANGUAGE="JScript"> var prevColor; function Hilite() { prevColor = style.color; element.style.color = "red"; element.style.cursor = "hand"; } </SCRIPT>
Code example: https://samples.msdn.microsoft.com/workshop/samples/components/htc/toc/toc.htm
See Also
Introduction to DHTML Behaviors, Implementing DHTML Behaviors in Script