HOME

XML Basic
XML HOME
XML Introduction
XML How to use
XML Syntax
XML Elements
XML Attributes
XML Validation
XML Browsers
XML Viewing
XML CSS Display
XML XSL Display
XML Data Islands
XML Parser
XML in Real Life

XML Advanced
XML Namespaces
XML CDATA
XML Encoding
XML Server
XML Applications
XML HTTP
XML Behaviors
XML Technologies

Examples/Quiz
XML Examples
XML Quiz


XML WebRing
Previous 5 Sites
Previous Site
Next Site
Next 5 Sites
Random Site
List Sites

Please visit our sponsors !

XML Behaviors - the new DHTML?

prev next

A behavior is a CSS attribute selector. It can point to an XML file that contains code to be executed against elements in a Web page.

Behaviors is not a W3C standard, but a Microsoft only technology.


Behaviors - What are they?

A behavior is a new CSS attribute selector.

A behavior selector can point to a separate XML file that contains code to be executed against XML or HTML elements in a Web page.

Did you understand that? A method for completely removing script code from HTML pages? That's great! Now we can start writing script libraries, and attach our scripts to any element we want!


How does it work?

Take a look at this HTML file. It has a <style> element that defines a behavior for the <h1> element:

<html>
<head>
<style>
h1 { behavior: url(behave.htc) }
</style>
</head>

<body>
<h1>Move your Mouse over me</h1>
</body>
</html>

Try it yourself with this example, and move the mouse over the text.

The behavior code is stored in an XML document behave.htc as shown below:

<component>
<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=255
   }
   function low_lite()
   {
   element.style.color=0
   }
</script>
</component>

The behavior file contains JavaScript. The script is wrapped in a <component> element. The component wrapper also contains the event handlers for the script. Nice behavior, isn't it?


prev next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISProtect
Password Protect
Your Web Pages



Your own Web Site?

Read W3Schools
Hosting Tutorial



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

University Online
Master Degree
Bachelor Degree


Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search