Dynamic HTML

Dynamic HTML
HTML
This box: view · talk · edit

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 — 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[citation needed], 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 DHTML style techniques were difficult to develop and debug due to varying degrees of support among web browsers of the technologies involved. Development became easier when Internet Explorer 5.0+, Mozilla Firefox 2.0+, and Opera 7.0+ adopted a shared Document Object Model.

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 the following way:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>DHTML example</title>
    <script type="text/javascript"> 
      function init() {
      myObj = document.getElementById("navigation");
      // .... more code
      }
      window.onload=init;
    </script>
  </head>
  <body>
    <div id="navigation"></div>
    <pre>
      Often the code is stored in an external file; this is done 
      by linking the file that contains the JavaScript. 
      This is helpful when several pages use the same script:
    </pre>
 
    <script type="text/javascript" src="myjavascript.js"></script>
  </body>
</html>

In the above code, the blue code represents the DOCUMENT TYPE declaration, which specifies which version of markup code is used to create the website. The red code shows browser detection Javascript, which enables web pages to adjust to browser application standards and requirements.

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.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title>Test</title>
    <style type="text/css">
      h2 {background-color: green; width: 100%}
      a {font-size: larger; background-color: red;} 
      a:hover {background-color: gold}
      #example1 {display: none; margin: 3%; padding: 4%; background-color: limegreen}
    </style>
    <script type="text/javascript">
      function changeDisplayState (id) {
        d=document.getElementById("showhide");
        e=document.getElementById(id);
        if (e.style.display == 'none' || e.style.display == "") {
          e.style.display = 'block';
          d.innerHTML = 'Hide example..............';
        } else {
          e.style.display = 'none';
          d.innerHTML = 'Show example';
        }
      }
    </script>
  </head>
  <body>
    <h2>How to use a DOM function</h2>
    <div><a id="showhide" href="javascript:changeDisplayState('example1')">Show example</a></div>
    <div id="example1">
      This is the example.
      (Additional information, which is only displayed on request)...
    </div>
    <div>The general text continues...</div>
  </body>
</html>

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Dynamic HTML — HTML dynamique HTML dynamique, de l anglais Dynamic HTML, souvent abrégé DHTML, est un nom générique donné à l ensemble des techniques utilisées par l auteur d une page web pour que celle ci soit capable de se modifier elle même en cours de… …   Wikipédia en Français

  • Dynamic HTML — усовершенствованная версия HTML, которая поддерживает объектную модель документа (Document Object Model). Наряду с возможностями форматирования DHTML поддерживает условную логику и динамическое выполнение. Синонимы английские: DHTML См. также:… …   Финансовый словарь

  • Dynamic HTML —   [engl.], dynamisches HTML …   Universal-Lexikon

  • dynamic HTML — DHTML kalba statusas T sritis informatika apibrėžtis Dinaminė ↑HTML kalba, patobulintas HTML kalbos variantas, kai galima atsižvelgiant į skaitytojo veiksmus keisti ↑tinklalapio turinį, vaizduojamą ↑naršykle, iš naujo neatsiunčiant tinklalapio iš …   Enciklopedinis kompiuterijos žodynas

  • Dynamic HTML — Die Begriffe DHTML, dynamisches HTML (engl. dynamic HTML) oder auch DOM Scripting bezeichnen bestimmte Webdesign Methoden, bei denen während der Anzeige einer Webseite diese selbst, ausgelöst durch Benutzereingaben, verändert wird. Der Begriff… …   Deutsch Wikipedia

  • Dynamic\ HTML — Abk. DHTML, mit CSS und/oder JavaScript erweitertes HTML. DHTML ist der Sammelbegriff für Lösungen, bei denen beliebige Elemente einer Webseite dynamisch verändert werden können. Beispielsweise können Ebenen (Layers) frei angeordnet und… …   Online-Wörterbuch Deutsch-Lexikon

  • Dynamic HTML — type of HTML language that includes additional options for HTML documents and allows flexible design and immediate interaction with the user, DHTML …   English contemporary dictionary

  • Dynamic HTML — …   Википедия

  • HTML Dynamique — HTML dynamique, de l anglais Dynamic HTML, souvent abrégé DHTML, est un nom générique donné à l ensemble des techniques utilisées par l auteur d une page web pour que celle ci soit capable de se modifier elle même en cours de consultation dans le …   Wikipédia en Français

  • HTML dynamique — HTML dynamique, de l anglais Dynamic HTML, souvent abrégé DHTML, est un nom générique donné à l ensemble des techniques utilisées par l auteur d une page web pour que celle ci soit capable de se modifier elle même en cours de consultation dans le …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”