spacer

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

home / experts / javascript / column22


Passing Objects to Behaviors

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

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


The Network for Technology Professionals

Search:

About Internet.com

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

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Workers Say Telework Is More Productive, Bosses Not So Sure · Kingston Debuts Power-Saving Memory Upgrades · Social Networking is King: Facebook Edges Google


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

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