CSS Attributes Index Pseudo-class Attributes
Specifies the location of the DHTML Behavior.
CSS |
{ behavior : url( sLocation ) } |
Script |
object.style. behavior [ = 'url( sLocation )" ] |
url( sLocation ) |
Specifies a script implementation of a behavior, where sLocation is an absolute or relative URL. |
url( #objID ) |
Specifies a binary implementation of a behavior, where objID is the ID attribute specified in an <OBJECT> tag. |
url( #default#behaviorName ) |
Specifies one of Microsoft Internet Explorer's default behavior, identified by its behaviorName. |
The property is read/write with no default value; the proposed cascading stylesheet ( CSS ) extension attribute is not inherited.
The following examples demonstrate various ways of using the behavior property on a page.
The following example implements an expanding/collapsing Table of Contents by applying the COLLAPSING behavior inline to the LI element. Note that in this case, the behavior is implemented as an HTML Component ( HTC ), and is defined in the file /sample/ul.htc
.
<ul>
<li style="behavior: url( ul.htc )">Authoring
<ul>
<li>...
<li>IE authoring tips
<li>...
</ul>
</ul>
This same example could have defined the behavior attribute in a separate <STYLE> block, as follows:
<style>
.collapsing { behavior: url( ul.htc ) }
</style>
<ul>
<li class="collapsing">Authoring
<ul>
<li>...
<li>IE authoring tips
<li>...
</ul>
</ul>
The behavior property could also have been set in client-side script in this manner:
<script language="JavaScript">
function window.onload ( ) {
topicID.style.behavior = "url( ul.htc )";
}
</script>
...
<ul>
<li id="topicID">Authoring
<ul>
<li>...
<li>IE authoring tips
<li>...
</ul>
</ul>
This feature requires Microsoft® Internet Explorer® 5 or later.
If the same expanding/collapsing example were to use a behavior implemented in C++ as an ActiveX control, the code would look slightly different. Note that the behavior attribute points to the ID property of the object specified in the <OBJECT> tag.
<style>
.collapsing { behavior: url( #myObject ) }
</style>
<object id="myObject" ... ></object>
<ul>
<li class="collapsing">Authoring
<ul>
<li>...
<li>IE authoring tips
<li>...
</ul>
</ul>
The following example attaches one of the persistence behaviors, saveHistory, to the INPUT element. The saveHistory behavior is implemented as one of the default behaviors introduced in Internet Explorer® 5.
<input class="persist1"
style="behavior: url( #default#saveHistory )">
DHTML Behaviors Overview, Using DHTML Behaviors