Internet Explorer 5.0 Preview, Part I: Passing Data to Behaviors - Doc JavaScript
Passing Data to Behaviors
A Behavior
describes the dynamic appearance of HTML elements that are associated with the specified Behavior
. As such, Behavior
does not include data of its own. It needs to operate on data that is stored in the Web page. This data is passed to the Behavior
through the named properties specified in the interface section of the scriptlet. The Automation
type of <IMPLEMENTS>
tag includes these properties:
<IMPLEMENTS TYPE="Automation">
<METHOD NAME="blink"/>
<PROPERTY NAME="x"/>
<PROPERTY NAME="y"/>
</IMPLEMENTS>
Notice the /
at the end of each PROPERTY
tag. It replaces the </PROPERTY>
tag that one would expect to find at the end of the PROPERTY
tag.
The property names specified in the scriptlet interface must match those in the DHTML elements. You can pick any names you want and as many properties as you want. In our example, we associate a Behavior
with a DIV
element. The x
and y
interface properties above are specified in the DIV
definition as follows:
<DIV CLASS="soccer" x="200" y="250">
Inside the script section of the scriptlet, you can use interface properties like any other local variables. In our Blinking Soccer example, we use the x
and y
properties to position a dynamic HTML element (DIV
):
style.pixelTop = x;
style.pixelLeft = y;
Created: July 19, 1998
Revised: July 19, 1998
URL: https://www.webreference.com/js/column22/data.html