可以,使用BehaviorSets or retrieves the location of the DHTML Behaviors .SyntaxHTML { behavior : sBehavior }
Scripting object.style.behavior [ = sBehavior ] Possible ValuessBehavior String that specifies or receives one of the following values.url(sLocation) Script implementation of a Dynamic HTML (DHTML) behavior, where sLocation is an absolute or relative URL.
url(#objID) Binary implementation of a DHTML behavior, where objID is the ID attribute specified in an object tag.
url(#default#behaviorName) Microsoft® Internet Explorer Default behavior, identified by its behaviorName.
The property is read/write for all objects except the following, for which it is read-only: currentStyle . The property has no default value. The Cascading Style Sheets (CSS) attribute is not inherited. Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see Dynamic Properties .ResYou can apply multiple behaviors to an element by specifying a space-delimited list of URLs for the behavior attribute, as shown in the following syntax: <ELEMENT STYLE="behavior:url(a1.htc) url(a2.htc) ..." >In the following section, one example demonstrates how you can apply two behaviors to an element to achieve a combination of effects. Conflicts resulting from applying multiple behaviors to an element are resolved based on the order in which the behavior is applied to the element. Each succeeding behavior takes precedence over the previous behavior. For example, if multiple behaviors set the element's color, the prevailing color is the one set by the behavior last applied to the element. The same rule applies in resolving name conflicts, such as with property, method, or event names exposed by multiple behaviors.Once the behavior property is defined for the element, the addBehavior method can be used to dynamically attach additional behaviors to the element.Note A behavior attached to an element by using the addBehavior method or by applying the proposed Cascading Style Sheets (CSS) behavior attribute inline is not automatically detached from the element when the element is removed from the document hierarchy. However, a behavior attached using a style rule defined in the document is detached automatically as the element is removed from the document tree.
ExamplesThe following examples demonstrate various ways of applying the behavior property on a page.
This example implements an expanding and collapsing table of contents by applying the behavior as an inline style to the li element. In this case, two behaviors implemented as HTML Component (HTC) have been applied to the element to achieve a combination of mouseover highlighting and expanding/collapsing effect.<UL>
<LI STYLE="behavior:url(ul.htc) url(hilite.htc)">HTML</LI>
<UL>
<LI><tla rid="tla_ie4"/> authoring tips</LI>
:
</UL>
</UL>
This example defines the behavior attribute in a separate style block.<style>
.CollapsingAndHiliting {behavior:url(ul.htc) url(hilite.htc)}
</style><UL>
<LI CLASS="CollapsingAndHiliting">HTML</LI>
<UL>
<LI><tla rid="tla_ie4"/> authoring tips</LI>
:
</UL>
</UL>
This example sets the behavior property in script.Hide Example<SCRIPT>
function window.onload()
{
idTopic1.style.behavior = "url(ul.htc) url(hilite.htc)";
}
</SCRIPT>
:
<UL>
<LI ID=idTopic1>HTML Authoring</LI>
<UL>
<LI><tla rid="tla_ie4"/> authoring tips</LI>
:
</UL>
</UL>If the expanding/collapsing example were to use a DHTML behavior implemented in C++ as an Microsoft ActiveX® control, the code would look slightly different. In this example, the behavior attribute points to the id property of the object specified in the object element.<STYLE>
.Collapsing { behavior:url(#myObject) }
</STYLE><OBJECT ID=myObject ... ></OBJECT>
<UL>
<LI CLASS="Collapsing">HTML Authoring</LI>
<UL>
<LI><tla rid="tla_ie4"/> authoring tips</LI>
:
</UL>
</UL>
Scripting object.style.behavior [ = sBehavior ] Possible ValuessBehavior String that specifies or receives one of the following values.url(sLocation) Script implementation of a Dynamic HTML (DHTML) behavior, where sLocation is an absolute or relative URL.
url(#objID) Binary implementation of a DHTML behavior, where objID is the ID attribute specified in an object tag.
url(#default#behaviorName) Microsoft® Internet Explorer Default behavior, identified by its behaviorName.
The property is read/write for all objects except the following, for which it is read-only: currentStyle . The property has no default value. The Cascading Style Sheets (CSS) attribute is not inherited. Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see Dynamic Properties .ResYou can apply multiple behaviors to an element by specifying a space-delimited list of URLs for the behavior attribute, as shown in the following syntax: <ELEMENT STYLE="behavior:url(a1.htc) url(a2.htc) ..." >In the following section, one example demonstrates how you can apply two behaviors to an element to achieve a combination of effects. Conflicts resulting from applying multiple behaviors to an element are resolved based on the order in which the behavior is applied to the element. Each succeeding behavior takes precedence over the previous behavior. For example, if multiple behaviors set the element's color, the prevailing color is the one set by the behavior last applied to the element. The same rule applies in resolving name conflicts, such as with property, method, or event names exposed by multiple behaviors.Once the behavior property is defined for the element, the addBehavior method can be used to dynamically attach additional behaviors to the element.Note A behavior attached to an element by using the addBehavior method or by applying the proposed Cascading Style Sheets (CSS) behavior attribute inline is not automatically detached from the element when the element is removed from the document hierarchy. However, a behavior attached using a style rule defined in the document is detached automatically as the element is removed from the document tree.
ExamplesThe following examples demonstrate various ways of applying the behavior property on a page.
This example implements an expanding and collapsing table of contents by applying the behavior as an inline style to the li element. In this case, two behaviors implemented as HTML Component (HTC) have been applied to the element to achieve a combination of mouseover highlighting and expanding/collapsing effect.<UL>
<LI STYLE="behavior:url(ul.htc) url(hilite.htc)">HTML</LI>
<UL>
<LI><tla rid="tla_ie4"/> authoring tips</LI>
:
</UL>
</UL>
This example defines the behavior attribute in a separate style block.<style>
.CollapsingAndHiliting {behavior:url(ul.htc) url(hilite.htc)}
</style><UL>
<LI CLASS="CollapsingAndHiliting">HTML</LI>
<UL>
<LI><tla rid="tla_ie4"/> authoring tips</LI>
:
</UL>
</UL>
This example sets the behavior property in script.Hide Example<SCRIPT>
function window.onload()
{
idTopic1.style.behavior = "url(ul.htc) url(hilite.htc)";
}
</SCRIPT>
:
<UL>
<LI ID=idTopic1>HTML Authoring</LI>
<UL>
<LI><tla rid="tla_ie4"/> authoring tips</LI>
:
</UL>
</UL>If the expanding/collapsing example were to use a DHTML behavior implemented in C++ as an Microsoft ActiveX® control, the code would look slightly different. In this example, the behavior attribute points to the id property of the object specified in the object element.<STYLE>
.Collapsing { behavior:url(#myObject) }
</STYLE><OBJECT ID=myObject ... ></OBJECT>
<UL>
<LI CLASS="Collapsing">HTML Authoring</LI>
<UL>
<LI><tla rid="tla_ie4"/> authoring tips</LI>
:
</UL>
</UL>
解决方案 »
- html页面使用JS验证,对动态项进行验证问题
- extjs gridpanel某列中加进度条
- 求助:父页面,怎么获取子页面的值
- 求助﹕寫一主控台應用程式,列出指定目錄及其子目錄的所有文件名稱,要求用遞歸演算法實現
- JScript与VBcript:在使用RecordSet对象的GetRows方法上不同,文中举例说明...
- 我动态增加了某个表格的列,那么怎么指定这个列的样式呢?可不可以直接指定css?
- 有没有办法使滚动条回到顶部?
- 最近写东西用的一些函数,提供给初学的朋友们,支持的UP啊~!
- 請教像郵箱附件的下載鏈接是怎樣做的!高分相送
- $("#id").append("html")添加html后页面显示问题。
- 请问如何把自己那一页设为无边框
- 谁有办法让文本文件自动“另存为”???
<script>function show(){alert(event.srcElement.outerHTML)}</script>
<input id=dg><textarea id=dg></textarea><div id=dg>div</div>
<div id=dg>div</div>