Content deleted Content added
Blocked Tags: Reverted Visual edit Mobile edit Mobile web edit Disambiguation links added |
No edit summary |
||
(17 intermediate revisions by 14 users not shown) | |||
Line 1:
{{Short description|Coding interactive or animated websites}}
{{
{{Html series}}
'''
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 and ones created by [[server-side scripting]] (such as [[PHP]], [[Python (programming language)|Python]], [[JavaServer Pages|JSP]] or [[ASP.NET]]) where the [[web server]] generates content before sending it to the client.
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 ==
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>{{Cite web |title=
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>{{cite book |last1=Ferguson |first1=Russ |last2=Heilmann |first2=Christian |title=Beginning JavaScript with DOM Scripting and Ajax |date=2013 |publisher=Berkeley, CA: Apress |pages=49–68 |doi=10.1007/978-1-4302-5093-7 |isbn=978-1-4302-5092-0 |s2cid=20526670 |url=https://link-springer-com.huaryu.kl.oakland.edu/content/pdf/10.1007/978-1-4302-5093-7.pdf |access-date=May 30, 2022}}</ref>
Line 26 ⟶ 27:
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 33:
Typically a web page using DHTML is set up in the following way:
<syntaxhighlight lang="
<!DOCTYPE html>
<html lang="en">
Line 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 95:
let displayElement = document.getElementById("toggle-me");
let textElement = document.getElementById("showhide");
textElement.addEventListener("click", function (
changeDisplayState(displayElement, textElement);
});
Line 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 150:
}
document.getElementById("clickable-link").addEventListener("click", function (
showMe();
});
|