spacer

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

home / experts / javascript / column22


Passing Objects to Behaviors

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

A Behavior operates on an object that is associated with a DHTML element. In our Blinking Soccer example, we first define a Behavior named soccer in the scriptlet file, and then, by assigning it to the CLASS attribute, we associate a DIV element with this Behavior:


<DIV CLASS="soccer" ...

Once a Behavior is associated with a DHTML element, any operation inside the Behavior definition script is assumed to operate on the DHTML element's object. When you manipulate properties inside the soccer Behavior, for example, you actually manipulate the properties of the relevant DHTML object. The following lines from the soccer scriptlet change the visibility and position of the DIV object in the Web page:


style.position = "absolute";
style.pixelTop = x;
style.pixelLeft = y;

Referencing an object's methods is more complicated. Internet Explorer 5.0 does not default to the relevant DHTML object. Instead, it provides you with the uniqueID mechanism. The uniqueID is a unique ID of the DHTML object that is currently being operated by the Behavior. When we want to use the blink() method in our Blinking Soccer example, we call it as uniqueID+".blink()". When we want to schedule the blinking msecs milliseconds in the future, we use:


window.setTimeout(uniqueID+".blink()", msecs);

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


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

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