DHTML-Introduction
Think of DHTML as not a singular technology on the contrary a combination of three
existing technologies glued well-balanced by the Dossier Entity Example (DOM):
1. HTML - For creating passage and form links and other period elements.
2. CSS - Style Sheets for besides formatting of contents and html plus other
added features such as positioning and layering content.
3. JavaScript - The programming tongue that allows you to accesses and
dynamically authority the characteristic properties of both HTML and Style Sheets.
The custom JavaScript accesses the properties of an HTML case is through
the Folder Thing Mould (DOM). The craft of the DOM is to expose all the
attributes of HTML and Style sheets to JavaScript control. All you demand to
know approximately the DOM is what JavaScript commands it accepts. Not that easy,
as disparate browsers keep their slightly at odds versions of the DOM, so
they access HTML properties differently as flourishing as fanfare them differently.
So how act you set an HTML component on a event and transform its property?
This is the gig of JavaScript. Obviously, I hypocrisy into all the details of
JavaScript or the DOM, on the other hand here is an case history of how JavaScript can alternate a
visibility of a style folio layer in both browsers.
Note: That every plenty of HTML has a residence all the more analogous a directory in a
phone book. When finding that group of HTML you admit to energy down the same
hierarchy means of searching for a agname in the ring tome such as
(state) Washington -> (City) Seattle -> (Listings) j -> (Name) Jessica
In JavaScript, a reference to this would be equivalent to
washington.seattle.j.jessica
Now Jessica may get more info such as her domicile and phone
number, so the JavaScript reference would be written this way.
washington.seattle.j.jessica.address
or
washington.seattle.j.jessica.phone
Lets inscribe the above metaphor to a DHTML information that contains a
layer [myLayer] with style attributes
[top,left,width,height,z-index,visibility,etc] and the layer contains a bit
of matter "myText" (Note that the visibility attribute is locate to hidden)
100px; height: 100px; z-index: 3; visibility: hidden;">
myText
In Netscape the residence to the DIV layer "myLayer" is
document.myLayer
in Explorer it is
document.all.myLayer.style
The W3C idea of identifying the inscription is
document.GetElementById(â myLayerâ ).style
To access the properties such as visibility under "myLayer" you would use
these addresses.
Netscape
document.myLayer.visibility
Explorer
document.all.myLayer.style.visibility
W3C
document.getElementById(â myLayerâ ).style.visibility
To pocket money the visibility of this layer you would advise a rate to your
JavaScript address.
Netscape
document.myLayer.visibility = "visible";
Explorer
document.all.myLayer.style.visibility = "visible";
W3C
document.getElementById(â myLayerâ ).style.visibility=â visibleâ ;
Now the formerly concealed layer is first off visible. This is essentially how
DHTML works, nevertheless deduce there are hundreds and hundreds of attribute
properties for text, images, documents and windows. Not all these
properties are supported in both browser and sometime accessing a property
requires a unusual also hurdles, however provided you stick to the average denominator
properties both browser apply then lifetime it a bit easier. I reccomend the
excellent DHTML reference jotter Compelling HTML - The Definitive Conductor by Danny
Goodman (O'Riley Books) It lists all of the DHMTL properties and their
cross browser compatibilities.
Published: January 15, 2008