Internet Explorer 5.0, Part II: Behavior Handler's Location - Doc JavaScript | 2
Behavior Handler's Location
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 anObject
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.
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)";
Created: August 11, 1998
Revised: August 11, 1998
URL: https://www.webreference.com/js/column23/location.html