CSS屬性behavior的文法使用

來源:互聯網
上載者:User

  behavior的文法:

  behavior : url ( url ) | url ( #objID ) | url ( #default#behaviorName )
取值:
url ( url ) : 使用絕對或相對 url 地址指定DHTML行為組件(.htc)
url ( #objID ) : 使用二進位實現(作為 ActiveX® 控制項)的行為。此處的 #objID 為 object 對象的 id 屬性值
url ( #default#behaviorName ) : IE的預設行為。由行為的名稱標識( #behaviorName )指定
說明:設定或檢索對象的DHTML行為。多個行為之間用空格隔開。


當多個附加到同一要素的行為發生衝突時,其結果取決於行為應用於要素的順序。後一個行為的優先權高於前一個行為。同樣的規則適用於不同行為提供的屬性、事件、方法所發生的名稱衝突。
可以使用 addBehavior 方法動態將行為附著到對象。
此屬性對於 currentStyle 對象而言是唯讀。對於其他對象而言是可讀寫的。
務必注意使用樣式表(CSS)的 behavior 屬性內聯定義或使用 addBehavior 方法附著的行為不會在對象從文檔樹中移除時被自動分離。而在文檔中的樣式表規則定義的行為會在對象從文檔樹中移除時被自動分離。
對應的指令碼特性為 behavior 。 

樣本:

  p { behavior: url(#default#download); }
div { behavior: url(fly.htc) url(shy.htc); }
div { behavior: url(#myObject); }


應用1:重新整理也保留輸入框裡面的文字

  .sHistory {}{behavior:url(#default#savehistory);}


應用2:呼叫指令碼

  <html>
<head>
<style>
h1 { behavior: url(behave.htc) }
</style>
</head>
<body>
<h1>把滑鼠放在這裡 </h1>
</body>
</html>
behave.htc

<component>
<attach for="element" event="onmouseover" handler="hig_lite" />
<attach for="element" event="onmouseout" handler="low_lite" />
<script type="text/javascript">
function hig_lite()
{
lor=255
}
function low_lite()
{
lor=0
}
</script>
</component>

  
注意:CSS 時盡量避免使用Behaviors技術

Internet Explorer Behaviors
它是什嗎?Internet Explorer 5 引入了行為 (behaviors)。behaviors 是一種通過使用 CSS 向 HTML 元素添加行為的方法。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.