dhtml|xml| Tutorials | Getting Started
Internet Explorer 5 introduces DHTML behavior. Behavior (behaviors) is a way to add DHTML functionality to HTML elements with the convenience of CSS.
Behavior-what is behavior?
IE 5 introduces DHTML behavior (DHTML Behaviors). Behavior (behaviors) is a way to add DHTML functionality to HTML elements with the convenience of CSS.
How does the act work? By using XML, we can link behavior to any element in the Web page and manipulate the elements.
DHTML behavior does not use <script> tags, and they use CSS properties named "Behavior." "Behavior" provides a URL to an HTC file that contains the actual behavior (the HTC file is written using XML).
Grammar:
Behavior:url (SOME_FILENAME.HTC)
Note: The Behavior property is supported by IE 5 and a higher version, and all other browsers will ignore it. This means Mozilla, Firefox, Netscape, and other browsers can only recognize regular content, and only IE 5+ can see DHTML behaviors.
Instance
The following HTML file has a <style> element that defines the behavior for the
h1 { behavior: url(behave.htc) } </style>
The XML document "BEHAVE.HTC" is as follows:
<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>
The behavior file contains a section of JavaScript and an event handler for scripting.
tiy (Please put your mouse over the text above in the example).
The following HTML file has a <style> element that defines the behavior for elements that have an ID of "typing":
behavior:url(typing.htc); font-family: ' Courier New ';} </style>
The XML document "TYPING.HTC" is as follows:
<attach for= "window" event= "onload" handler= begintyping "/><method name=" type "/><script type=" text/ JavaScript ">var i,text1,text2,textlength,tfunction begintyping () {i=0text1=element.innertexttextlength= text1.lengthelement.innertext= "" Text2= "" T=window.setinterval (element.id+ ". Type ()", speed)}function type () {text2= Text2+text1.substring (i,i+1) element.innertext=text2i=i+1if (i==textlength) {clearinterval (t)}}</script>