spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column22


Passing Data to Behaviors

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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;

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Created: July 19, 1998
Revised: July 19, 1998

URL: http://www.webreference.com/js/column22/data.html