spacer

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

home / experts / javascript / column23


Behavior Handler's Location

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

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.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: August 11, 1998
Revised: August 11, 1998

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