XML Getting Started Tutorial: XML DHTML behavior

Source: Internet
Author: User
Tags add contains window
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>


Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.