从5.5版本开始,Internet Explorer(IE)开始支持Web 行为的概念。这些行为是由后缀名为.htc的脚本文件描述的,它们定义了一套方法和属性程序员几乎可以把这些方法和属性应用到HTML页面上的任何元素上去。
Style.htc文件源码
<public:attach event="onfocus" onevent="f_onfocus()"/>
<public:attach event="onblur" onevent="f_onblur()"/>
<script>
function f_onfocus() {
element.style.borderColor = "#0254a6";
element.style.posLeft += 5;
}
function f_onblur() {
element.style.borderColor = "#cccccc";
element.style.posLeft -= 5;
}
</script>
样式调用Sysle.htc
input[type="text"] {border:1px solid #ccc;height:18px;line-height:18px;background: url(../Styles/images/input-bg.gif) top left repeat-x #f6f6f6;BEHAVIOR:url('../Styles/Style.htc');}