Content deleted Content added
Anton.bersh (talk | contribs) Update lead as per Talk |
No edit summary |
||
(26 intermediate revisions by 22 users not shown) | |||
Line 1:
{{Short description|Coding interactive or animated websites}}
{{
{{Html series}}
'''Dynamic HTML''', or '''DHTML''', is a term which was used by some browser vendors to describe the combination of [[HTML]], [[Style sheet (web development)|style
DHTML (Dynamic HTML) allows scripting languages, such as JavaScript, to
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
DHTML is the predecessor of [[Ajax (programming)|Ajax]] and DHTML pages are still request/reload-based. Under the DHTML model, there may not be any interaction between the client and server after the page is loaded; all processing happens on the client side. By contrast, Ajax extends features of DHTML to allow the page to initiate network requests (or 'subrequest') to the server even after page load to perform additional actions. For example, if there are multiple [[Tab (interface)|tabs]] on a page, the pure DHTML approach would load the contents of all tabs and then dynamically display only the one that is active, while AJAX could load each tab only when it is really needed.
== Uses ==
DHTML allows authors to add effects to their pages that are otherwise difficult to achieve, by changing the [[Document Object Model]] (DOM) and page style. The combination of HTML, CSS, and JavaScript offers ways to:
* Animate text and images in their document.
Line 20 ⟶ 21:
* Include rollover buttons or drop-down menus.
A less common use is to create browser-based action games. Although a number of games were created using DHTML during the late 1990s and early 2000s,<ref>{{
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.<ref>{{
DHTML support with extensive DOM access was introduced with [[Internet Explorer 4.0]]. Although there was a basic dynamic system with [[Netscape Navigator|Netscape Navigator 4.0]], not all HTML elements were represented in the DOM. When DHTML-style techniques became widespread, varying degrees of support among web browsers for the technologies involved made them difficult to develop and [[debug]]. Development became easier when [[Internet Explorer 5|Internet Explorer 5.0+]], [[Firefox|Mozilla Firefox]] 2.0+, and [[Opera (web browser)|Opera]] 7.0+ adopted a shared [[Document Object Model|DOM]] inherited from [[ECMAScript]].
== Structure of a web page ==
Line 32 ⟶ 33:
Typically a web page using DHTML is set up in the following way:
<syntaxhighlight lang="
<!DOCTYPE html>
<html lang="en">
Line 60 ⟶ 61:
The following code illustrates an often-used function. An additional part of a web page will only be displayed if the user requests it.
<syntaxhighlight lang="
<!DOCTYPE html>
<html>
Line 93 ⟶ 94:
let displayElement = document.getElementById("toggle-me");
let textElement = document.getElementById("showhide")
textElement.addEventListener("click", function (
changeDisplayState(displayElement, textElement);
});
Line 105 ⟶ 106:
==Document Object Model==
{{main|Document Object Model}}
DHTML is not a technology in and of itself; rather, it
The DOM API is the foundation of DHTML, providing a structured interface that allows access and manipulation of virtually anything in the document. The HTML elements in the document are available as a hierarchical [[tree (data structure)|tree]] of individual objects, making it possible to 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.
Line 119 ⟶ 120:
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.
<syntaxhighlight lang="
<!DOCTYPE html>
<html lang="en">
Line 149 ⟶ 150:
}
document.getElementById("clickable-link").addEventListener("click", function (
showMe();
});
Line 166 ⟶ 167:
== External links ==
{{Sister project|project=wikibooks|text=JavaScript/DHTML}}
* [http://www.quirksmode.org/ QuirksMode], a comprehensive site with test examples and instructions on how to write DHTML code
* [http://www.yourhtmlsource.com/javascript/dhtmlexplained.html Introductory DHTML Tutorial]
|