spacer

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

home / experts / javascript / column23


Behavior Handler's Location

Developer News
HP to Microsoft: Thanks for Nothing
iPhone Remains Left Out as Android Scores Flash
The Year of Living the OpenSocial

You can specify the URL location of the Behavior scriptlet using either HTML or JavaScript. The HTML syntax is:

{behavior:url(myBehavior)}

and the JavaScript syntax is:

object.style.behavior[ = url(myBehavior) ]

where myBehavior can take the following forms:

  • myURL. Relative or absolute URL of a scriptlet implementation of a behavior. This is the case we are mostly dealing with in this column.
  • #objID. The ID attribute specified in an Object tag. Refers to a binary implementation of a behavior.
  • #_IE_. One of Internet Explorer's default behaviors. These behaviors implement the new persistency functionality in Internet Explorer 5.0.
There are several ways to specify the Behavior attribute of the element's style. In our Connect Three game, we first define tripleBox, a generic style label that applies to all element types:

<STYLE>
  .tripleBox{behavior:url(xmdbehavior.sct)} 
</STYLE>

and then we include the CLASS="tripleBox" specification in each of the nine IMG statements:

<IMG CLASS="tripleBox" x="50" y="50" onBoxClick="handleBoxClick()" 
onBoxLoad="handleBoxLoad(1,1)">

One alternative is to omit the <STYLE> section altogether, and specify the behavior URL directly in each of the nine IMG statements:

<IMG STYLE="behavior:url(xmdbehavior.sct)" x="50" y="50" 
onBoxClick="handleBoxClick()" onBoxLoad="handleBoxLoad(1,1)">

Yet another alternative is to specify the behavior URL in the scriptlet itself, similarly to the other style properties set there. The first few JavaScript lines in the scriptlet would have been read like this:

style.position = "absolute";
style.pixelTop = y;
style.pixelLeft = x;
style.behavior = "url(xmdbehavior.sct)";

http://www.internet.com

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

webref The latest from WebReference.com Browse >
Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script · Book Review: Content Rich
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Gateway Launches New Core i7-powered FX-Series Gaming PCs · Review: Lenovo ThinkPad SL300 · EBay, Alternative Site Holiday Resources for Sellers


Created: August 11, 1998
Revised: August 11, 1998

URL: http://www.webreference.com/js/column23/location.html