为 id 为 "typing" 的元素定义行为
导读:HTML 文件中有一个 元素,它为 id 为 "typing" 的元素界说了一个举止: #typing { behavior:url(behave_typing.htc ; font-family:'courier new';...
HTML 文件中有一个 元素,它为 id 为 "typing" 的元素界说了一个举止:
#typing
{
behavior:url(behave_typing.htc);
font-family:'courier new';
}
IE5 introduced DHTML behaviors.
Behaviors are a way to add DHTML functionality to HTML elements
with the ease of CSS.
How do behaviors work?
By using XML we can link behaviors to any element in a web page
and manipulate that element.
上面是 XML 文档 "behave.htc":
var i,text1,text2,textLength,t; function beginTyping() { i=0; text1=element.innerText; textLength=text1.length; element.innerText=""; text2=""; t=window.setInterval(element.id+".type()",speed); } function type() { text2=text2+text1.substring(i,i+1); element.innerText=text2; i=i+1; if (i==textLength) { clearInterval(t); } }
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 为 id 为 "typing" 的元素定义行为
本文地址: https://pptw.com/jishu/668459.html