Academic Tutorials



English | French | Portugese | German | Italian
Google

Home Source Codes E-Books Downloads Contact Us About Us

XML Tutorial
XML Introduction
XML How to use
XML Syntax
XML Elements
XML Attributes
XML Validation
XML Validator
XML Browsers
XML Viewing
XML CSS
XML XSL
XML Data Island
XML Parser
XML in Real Life
XML Namespaces
XML CDATA
XML Encoding
XML Server
XML Application
XML HTTP Request
XML Save Data
XML Behaviors
XML Technologies
XML Editors
XML Summary
XML as Data Source

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


XML DHTML Behaviors
Previous Next

Behaviors

Behavioral extensions provide a standard way for declaration of standalone behaviors that can be attached to any HTML or XML element, without modification of the DTD. Partly based on extensions to Cascading Style Sheets (CSS), these behaviors can be applied to multiple documents using the existing CSS linking mechanisms.

Through XML we can link behaviors to any element in a web page and manipulate that element.

DHTML are using a CSS attribute called "behavior" in place of <script> tag.This "behavior" specifies a URL to an HTC file which contains the actual behavior (The HTC file is written in XML)

Syntax

behavior: url(some_filename.htc)

Note: The behavior attribute is only supported by IE 5 and higher. All other browsers will ignore it, means that Mozilla, Firefox, Netscape and other browsers will only see the regular content and IE 5+ can see the DHTML behaviors.



Benefits:

DHTML behaviors makes things easier for everyone involved in the Web development process and add great value to a Web application environment. In the real world, this environment consists of a team of content authors, designers, and developers. Content authors are responsible for writing content. Designers determine what interactive effects can be added to the content, while developers implement those effects.

The following section outlines the advantages and benifits by using behaviors.

  • Behaviors Provide a Means for code reuse and Script Encapsulation
  • Behaviors allow Designers to Add Interactive Effects with a Simple Declarative Syntax
  • Behaviors Isolate Script from Content, Resulting in more manageable and Cleaner Pages
  • Behaviors engross Easy-to-Create Components

Behaviors Provide a Means for code reuse and Script Encapsulation

With behaviors,it is very easy to add interactive effects as encapsulated components that can be reused across multiple pages. For example, consider one of the more popular effects made possible in Internet Explorer 4.0: onmouseover highlights. Through the use of CSS rules, and the ability to change styles on the fly, it is easy to achieve this effect on a page. In Internet Explorer 4.0, the way to implement onmouseover highlights on a list item, or li, would be to handle the onmouseover and onmouseout events in this manner:


<HEAD>
<STYLE>
HILITE
{ color:red;letter-spacing:2; }
</STYLE>
</HEAD>

<BODY>
<UL>
<LI onmouseover="this.className='HILITE'"
onmouseout ="this.className=''">HTML Authoring</LI>
</UL>
</BODY>
 


Beginning with Internet Explorer 5, a DHTML behavior can be implemented to achieve this effect. This behavior, when applied to an li element, extends the list item's default behavior to change its color when the user moves the mouse over it.

The following example implements a behavior in the form of an HTML Component (HTC) file, which is contained in the hilite.htc file, to achieve the onmouseover highlight effect. The behavior is applied to the li with the familiar style block, using the proposed CSSbehavior attribute that specifies the location of the behavior. With the behavior applied, the preceding code can look something like this in Internet Explorer 5 and later:


<HEAD>
<STYLE>
LI {behavior:url(hilite.htc)}
</STYLE>
</HEAD>

<BODY>
<UL>
<LI>HTML Authoring</LI>
</UL>
</BODY>
 


Behaviors allow Designers to Add Interactive Effects with a Simple Declarative Syntax

Currently, the task of adding interactive effects to a page can involve a lengthy iterative process between the designer and the developer trying to give the page that perfect look. The designer, usually with limited programming background, mocks up the desired effect on the content in a desktop publishing environment, and works closely with the developer to achieve the same effect on the page, usually with Dynamic HTML.

With behaviors, a developer can work independently on encapsulating the desired effect in a separate file, while the designer applies that behavior to elements on the page with a few CSS attributes. By providing a simple declarative syntax, requiring no prerequisite knowledge of scripting and DHTML, behaviors empower Web designers to easily add interactive effects to an otherwise static content. As seen in the preceding example, adding an onmouseover highlighting effect on a list item is as easy as adding the familiar style block, in exactly the same way a style is attached to an element through CSS.


Behaviors Isolate Script from Content, Resulting in more manageable and Cleaner Pages

Behaviors provide easy partition of script from contents, as it moves all script contained in a page into a separate file. The previous example demonstrated how the script to handle the onmouseover and onmouseout events was moved to a separate file, hilite.htc. This example can be extended to implement hiding content and display it, making it even easier to see how behaviors can make a difference, and how script isolation results in a cleaner, script-free page.

The following example demonstrates the use of the two effects, onmouseover highlight and displaying/hiding content, in a table of contents scenario. The same example has been implemented two different ways:

  • For Internet Explorer 5.0 & later, using Dynamic HTML

    Using DHTML behaviors, the code to implement the same table of contents looks a lot cleaner, as most of the script is isolated into a separate file.


<HEAD>
<STYLE>
CollapsingAndHiliting {behavior:url(ul.htc) url(hilite.htc))}
A {behavior:url(hilite.htc)}
</STYLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">


<FONT SIZE=1 FACE="Verdana,Arial,Helvetica">

<UL>
<LI CLASS="CollapsingAndHiliting" CHILD="Topics1">HTML Authoring</LI>
<UL ID="Topics1">
<LI><A HREF="/workshop/author/default.asp">Beginner's Guide</A></LI>
<LI><A HREF="/workshop/author/default.asp">IE4.0 Authoring Tips</A></LI>
<LI><A HREF="/workshop/author/default.asp">HTML Coding Tips</A></LI>
<LI><A HREF="/workshop/author/default.asp">Table Cell Backgrounds</A></LI>
<LI><A HREF="/workshop/author/default.asp">Drop Caps</A></LI>
<LI><A HREF="/workshop/author/default.asp">Quote Server</A></LI>
<LI><A HREF="/workshop/author/default.asp">HTML Wizard</A></LI>
<LI><A HREF="/workshop/author/default.asp">Dr. HTML</A></LI>
<LI><A HREF="/workshop/author/default.asp">HTML Coding FAQ for Internet Explorer</A></LI>
<LI><A HREF="/workshop/author/default.asp">SGML DTD for Internet Explorer 3.0 Markup</A></LI>
<LI><A HREF="/workshop/author/default.asp">Authoring Basics</A></LI>
<LI><A HREF="/workshop/author/default.asp">Authoring Effective Pages</A></LI>
<LI><A HREF="/workshop/author/default.asp">Designing Efficient Pages</A></LI>
<LI><A HREF="/workshop/author/default.asp">Using Frames</A></LI>
</UL>
<LI><A HREF="/workshop/author/default.asp">HTML Help Authoring</A></LI>
<LI CLASS="CollapsingAndHiliting" CHILD="Topics2">HTML References</LI>
<UL ID="Topics2">
<LI><A HREF="/workshop/author/default.htm">Elements</A></LI>
<LI><A HREF="/workshop/author/default.htm">Character Sets</A></LI>
</UL>
<LI CLASS="CollapsingAndHiliting" CHILD="Topics3">HTML Applications (HTA)</LI>
<UL ID="Topics3">
<LI><A HREF="/workshop/author/default.htm">Overview</A></LI>
<LI><A HREF="/workshop/author/default.htm">Reference</A></LI>
</UL>
</UL>
</FONT>
</BODY>


Behaviors engross Easy-to-Create Components

HTC files provide the easiest and quickest way to create DHTML behaviors using scripting languages such as Microsoft Visual Basic Scripting Edition (VBScript) and Microsoft JScript (compatible with ECMA 262 language specification). However, like any component used on the Internet today, behaviors implemented using Microsoft Windows Script Component (WSC) or Microsoft Visual C++.
The behavior used in the previous example to apply onmouseover event it's effect was implemented as an HTC and involves just a few lines of code. The code consists mainly of script, with a number of custom elements used to define the behavior. Notice that the use of the PUBLIC:ATTACH element that allows an HTC to listen in on events fired on the element on the page and to handle the events appropriately. So it provides the means to encapsulate the event handling code that would otherwise be put on the page.


<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="Hilite()" />
<PUBLIC:ATTACH EVENT="onmouseout" ONEVENT="Restore()" />
<SCRIPT LANGUAGE="JScript">
var normalColor;

function Hilite()
{
if (event.srcElement == element)
{
normalColor = style.color;
runtimeStyle.color = "red";
runtimeStyle.cursor = "hand";
}
}

function Restore()
{
if (event.srcElement == element)
{
runtimeStyle.color = normalColor;
runtimeStyle.cursor = "";
}
}
</SCRIPT>


Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previous Next

Keywords: XML DHTML Behaviors, internet explorer dhtml, internet explorer dhtml,xml web service


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
AJAX Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PHP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
XML Web Services Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz

Privacy Policy
Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.