Search: in
Dynamic HTML
Dynamic HTML in Encyclopedia Encyclopedia
  Tutorials     Encyclopedia     Videos     Books     Software     DVDs  
       





Dynamic HTML

Dynamic HTML, or DHTML, is an umbrella term for a collection of technologies used together to create interactive and animated web sites[1] by using a combination of a static markup language (such as HTML), a client-side scripting language (such as JavaScript), a presentation definition language (such as CSS), and the Document Object Model.[2]

DHTML allows scripting languages to change variables in a web page's definition language, which in turn affects the look and function of otherwise "static" HTML page content, after the page has been fully loaded and during the viewing process. Thus the dynamic characteristic of DHTML is the way it functions while a page is viewed, not in its ability to generate a unique page with each page load.

By contrast, a dynamic web page is a broader concept, covering any web page generated differently for each user, load occurrence, or specific variable values. This includes pages created by client-side scripting, and ones created by server-side scripting (such as PHP, Perl, JSP or ASP.NET) where the web server generates content before sending it to the client.

Contents


Uses

DHTML allows authors to add effects to their pages that are otherwise difficult to achieve. For example, DHTML allows the page author to:

  • Animate text and images in their document, independently moving each element from any starting point to any ending point, following a predetermined path or one chosen by the user.
  • Embed a ticker that automatically refreshes its content with the latest news, stock quotes, or other data.
  • Use a form to capture user input, and then process and respond to that data without having to send data back to the server.
  • Include rollover buttons or drop-down menus.

A less common use is to create browser-based action games. During the late 1990s and early 2000s, a number of games were created using DHTML, but differences between browsers made this difficult: many techniques had to be implemented in code to enable the games to work on multiple platforms. Recently browsers have been converging towards the web standards, which has made the design of DHTML games more viable. Those games can be played on all major browsers and they can also be ported to Widgets for Mac OS X and Gadgets for Windows Vista, which are based on DHTML code.

The term "DHTML" has fallen out of use in recent years as it was associated with practices and conventions that tended to not work well between various web browsers. DHTML may now be referred to as unobtrusive JavaScript coding (DOM Scripting), in an effort to place an emphasis on agreed-upon best practices while allowing similar effects in an accessible, standards-compliant way.

Basic DHTML support was introduced with Internet Explorer 4.0, although there was a basic dynamic system with Netscape Navigator 4.0. When it originally became widespread, varying degrees of support among web browsers for the technologies involved made DHTML-style techniques difficult to develop and debug. Development became easier when Internet Explorer 5.0+, Mozilla Firefox 2.0+, and Opera 7.0+ adopted a shared DOM.

More recently, JavaScript libraries such as jQuery have abstracted away much of the day-to-day difficulties in cross-browser DOM manipulation.

Structure of a web page

Typically a web page using DHTML is set up in the following way:

Example: Displaying an additional block of text

The following code illustrates an often-used function. An additional part of a web page will only be displayed if the user requests it.

Introduction to Dynamic HTML

Dynamic HTML (DHTML) is a set of innovative features originally introduced in Microsoft Internet Explorer 4.0. By enabling authors to dynamically change the rendering and content of a Web page as the user interacts with it, DHTML enables authors to create visually compelling Web sites without the overhead of server-side programs or complicated sets of controls to achieve special effects.

With DHTML, you can easily add effects to your pages that previously were difficult to achieve. For example, you can:

  • Hide content until a given time elapses or the user interacts with the page.
  • Animate text and images in your document, independently moving each element from any starting point to any ending point, following a predetermined path or one chosen by the user.
  • Embed a ticker that automatically refreshes its content with the latest news, stock quotes, or other data.
  • Use a form to capture user input, and then instantly process and respond to that data.

DHTML achieves these effects by modifying the in-memory representation of the current document and automatically reformatting it to show changes. It does not reload the document, load a new document, or require a distant server to generate new content. Instead, it uses the user's computer to calculate and carry out changes. This means a user does not wait for text and data to complete time-consuming roundtrips to and from a server before seeing the results. Furthermore, DHTML does not require additional support from applications or embedded controls to make changes. Typically, DHTML documents are self-contained, using styles and a script to process user input and directly manipulate the HTML elements, attributes, styles, and text of the document.

In short, DHTML eliminates the shortcomings of static pages. You can create innovative Web sites, on the Internet or on an intranet, without having to sacrifice performance for interactivity. Not only does DHTML enhance the user's perception of your documents, it also improves server performance by reducing requests to the server.

The following sections describe DHTML in more detail and how to use it.

  • Document Object Model
  • Dynamic Styles
  • Dynamic Content
  • Positioning and Animation
  • Filters and Transitions
  • Font Download
  • Data Binding
  • Summary
  • Related Topics

Document Object Model

DHTML is not a technology in and of itself; rather, it is the product of three related and complementary technologies: HTML, Cascading Style Sheets (CSS), and script. To allow scripts and components to access features of HTML and CSS, the contents of the document were represented as objects in a programming model known as the Document Object Model (DOM).

The DOM API is the foundation of DHTML, providing a structured interface that allows you to access and manipulate virtually anything within the document. The HTML elements in the document are available as individual objects, meaning you can examine and modify an element and its attributes by reading and setting properties and by calling methods. The text between elements is also available through DOM properties and methods.

The DOM also provides access to user actions such as pressing a key and clicking the mouse. You can intercept and process these and other events by creating event handler functions and routines. The event handler receives control each time a given event occurs and can carry out any appropriate action, including using the DOM to change the document.

Dynamic Styles

Dynamic styles are a key feature of DHTML. By using CSS, you can quickly change the appearance and formatting of elements in a document without adding or removing elements. This helps keep your documents small and the scripts that manipulate the document fast.

The object model provides programmatic access to styles. This means you can change inline styles on individual elements and change style rules using simple script-based programming. These scripts can be written in JavaScript, Microsoft JScript, or Microsoft Visual Basic Scripting Edition (VBScript).

Inline styles are CSS style assignments that have been applied to an element using the style attribute. You can examine and set these styles by retrieving the style object for an individual element. For example, to highlight the text in a heading when the user moves the mouse pointer over it, you can use the style object to enlarge the font and change its color, as shown in the following simple example.

   Dynamic Styles  language="JavaScript"> function showMe() {     MyHeading.style.color = "red";     MyList.style.display = ""; }    onclick="showMe()">  

id="MyHeading">Welcome to Dynamic HTML!

You can do the most amazing things with the least bit of effort. Just click and see!
    id="MyList" style="display:none">
  • Change the color, size, and typeface of text
  • Show and hide text
  • And much, much more

    And this is just the beginning!
  • Data Binding

    Data binding is a DHTML feature that lets you easily bind individual elements in your document to data from another source, such as a database or comma-delimited text file. When the document is loaded, the data is automatically retrieved from the source and formatted and displayed within the element.

    One practical way to use data binding is to automatically and dynamically generate tables in your document. You can do this by binding a table element to a data source. When the document is viewed, a new row is created in the table for each record retrieved from the source, and the cells of each row are filled with text and data from the fields of the record. Because this generation is dynamic, the user can view the page while new rows are created in the table. Additionally, once all the table data is present, you can manipulate (sort or filter) the data without requiring the server to send additional data. The table is simply regenerated, using the previously retrieved data to fill the new rows and cells of the table.

    Another practical use of data binding is to bind one or more elements in the document to specific fields of a given record. When the page is viewed, the elements are filled with text and data from the fields in that record, sometimes called the "current" record. A simple example is a form letter in which the name, e-mail address, and other details about an individual are filled from a database. To adapt the letter for a given individual, you simply specify which record should be the current record. No other changes to the letter are needed.

    Yet another practical use is to bind the fields in a form to fields in a record. Not only can the user view the content of the record, but the user can also change that content by changing the settings and values of the form. The user can then submit these changes so that the new data is uploaded to the source for example, to the HTTP server or database.

    To provide data binding in your documents, you must add a data source object (DSO) to your document. This invisible object is simply an ActiveX control or Java applet that knows how to communicate with the data source. The following example shows how easy it is to bind a table to a DSO. When viewed, this example displays the first three fields from all the comma-delimited records of the file "sampdata.csv" in a clear, easy-to-read table.

      DataURL Example   classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83" ID="sampdata">     name="DataURL" value="sampdata.csv">     name="UseHeader" value="True">   border="1" datasrc="#sampdata">
    
    
    A B C
    datafld="a"> datafld="b"> align="right"> datafld="c">

    References

    http://sourceforge.net/projects/jscalendar/

    External links

    ar: bg:DHTML cs:DHTML de:Dynamic HTML es:HTML din mico eu:DHTML fa: fr:HTML dynamique ko:DHTML hi: (Dynamic HTML) id:Dynamic HTML it:DHTML he:Dynamic HTML nl:Dynamic HTML ja: HTML km: HTML pl:Dynamiczny HTML pt:DHTML ro:DHTML ru:DHTML sk:Dynamick HTML fi:DHTML sv:DHTML tr:DHTML uk:DHTML vi:HTML ng zh: HTML






    Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article



    Search for Dynamic HTML in Tutorials
    Search for Dynamic HTML in Encyclopedia
    Search for Dynamic HTML in Videos
    Search for Dynamic HTML in Books
    Search for Dynamic HTML in Software
    Search for Dynamic HTML in DVDs
    Search for Dynamic HTML in Store




    Advertisement




    Dynamic HTML in Encyclopedia
    Dynamic_HTML top Dynamic_HTML

    Home - Add TutorGig to Your Site - Disclaimer

    ©2011-2013 TutorGig.info All Rights Reserved. Privacy Statement