Internet Explorer Behaviors
它是什么?Internet Explorer 5 引入了行为 (behaviors)。behaviors 是一种通过使用 CSS 向 HTML 元素添加行为的方法。
为什么要避免它?只有 Internet Explorer 支持 behavior 属性。
用什么代替?请使用 JavaScript 和 HTML DOM 取而代之。
例子 1 - Mouseover Highlight
下面的 HTML 文件中有一个 <style> 元素,它为 <h1> 元素定义了一个行为:
<html> <head> <style type="text/css"> h1 { behavior: url(behave.htc) } </style> </head> <body> <h1>Mouse over me!!!</h1> </body> </html>
下面是 XML 文档 "behave.htc":
<attach for="element" event="onmouseover" handler="hig_lite" /> <attach for="element" event="onmouseout" handler="low_lite" /> <script type="text/javascript"> function hig_lite() { element.style.color='red'; } function low_lite() { element.style.color='blue'; } </script>
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/jiqiao/j51838.shtml