Sunday, June 19, 2011

understanding java script

One of the best ways to understand why JavaScript is so valuable on the client
computer is to see how scripts add life to otherwise flat HTML documents. Popular
categories of scripting implementations include interactive user interfaces, instantaneous
form validation, small data collection lookups (the data is embedded in the
document for JavaScript to search through), multiple frame management, and, in
more recent browsers, dynamic designs that allow dragging elements around the
page. At the same time, it is important to recognize when JavaScript is not the preferred
technology.
This chapter introduces the concept of a document object model (DOM). You can
visualize the object model as a kind of road map to the page elements that become
objects in the browser’s memory as the page loads into the browser. Figure II-1 is
a roadmap for a hypothetical Web page that contains one of each kind of element
recognized as an object in the lowest common denominator model. The containment
notion conveyed by the grey boxes reinforces the way script statements reference
objects, starting with the window object at the top of the hierarchy. For example,
to address a text box, you assemble a reference like this: window.document.
formName.textBoxName.
After a discussion of how “dot syntax” works, the chapter ends with an introduction
to the way objects distinguish themselves from each other by way of their
properties, methods, and event handlers. An object’s properties are like adjectives
that describe various characteristics of the object. Methods are like an object’s
verbs, which provide scripts with ways to ask objects to do something. Event handlers
denote the kinds of user and system actions (such as clicking on a button)
that trigger script statements to run. Once you know an object’s properties, methods,
and event handlers, you know everything your scripts can do to make it
“dance.”

No comments:

Post a Comment