HTML and CSS Reference
In-Depth Information
Figure 7-2. The window object as it appears logged in Safari's error console
Scrolling through this list, you will find interesting information about what you can
manipulate from JavaScript. For example, you'll see the type of data you can work
with from JavaScript, such as Arrays, Booleans, and so on. You'll also see a list of
the HTML elements in the form of HTMLAnchorElement , HTMLImageElement ,
HTMLParagraphElement , and so forth. JavaScript is a prototype-oriented language,
meaning it does not have classes (unlike Java or Adobe Flash's ActionScript) but instead
utilizes "prototype" objects that provide a basis for other objects. These prototype ob-
jects can build on each other, creating a "prototype chain" that allows prototype ob-
jects to inherit properties and methods from other prototype objects. This process is
analogous to the inheritance capabilities of classes in other object-oriented languages.
The HTML element-like entries in the console output shown in Figure 7-2 are the pro-
totype objects that define the properties and methods different HTML elements have
when represented in the DOM. For instance, the stop() and play() methods defined
for the video element that stop and play a video loaded in that element can be found
through exploring the HTMLVideoElement object represented in the DOM (explor-
ing this element, you'll discover it actually inherits these methods from HTMLMedi-
aElement ).
Note When logging HTML elements that appear on the page (by referencing them
by their ID, for instance), the error console will normally show the actual HTML code
 
Search WWH ::




Custom Search