HTML and CSS Reference
In-Depth Information
applications that support the standard. The first version of the ECMA standard is doc-
umented in the ECMA-262 specification. Both JavaScript (Mozilla) and JScript
(Microsoft IE) are really just a superset of ECMAScript and strive to be compatible
with ECMAScript even though they have some of their own additions. 5 After ECMA-
Script was released, W3C began work on a standardized DOM, known as DOM Level
1, and recommended in late 1998. DOM Level 2 was published in late 2000. The cur-
rent release of the DOM specification was published in April 2004. By 2005, large parts
of W3C DOM were well supported by common ECMAScript-enabled browsers,
including Microsoft Internet Explorer version 6 (2001), Gecko-based browsers (like
Mozilla Firefox, and Camino), Konqueror, Opera, and Safari. In fact 95% of all modern
browsers support the DOM specifications.
For the latest information on the latest ECMA-252 edition 5, see http://www.ecmas-
1.9.1 JavaScript Objects
Everything you do in JavaScript involves objects, just as everything you do in real life
involves objects. JavaScript sees a Web page as many different objects, such as the
browser object, the document object, and each element of the document as an object;
for example, forms, images, and links are also objects. In fact every HTML element in
the page can be viewed as an object. HTML H1, P, TD, FORM, and HREF elements are
all examples of objects. JavaScript has a set of its own core objects that allow you to
manipulate strings, numbers, functions, dates, and so on, and JavaScript allows you to
create your own objects. When you see a line such as:
document.write("Hello, world");
the current page is the document object. After the object, there is a dot that separates
the object from the write method. A method is a function that lets the object do some-
thing. The method is always followed by a set of parentheses that might or might not
contain data. In this example the parentheses contain the string “Hello, world” telling
JavaScript to write this string in the document window, your browser. In Chapter 8,
“Objects,” we discuss objects in detail. Because everything in JavaScript is viewed as an
object, it is important to understand the concept from the start.
1.9.2 The Document Object Model
What is the DOM? A basic Web document consists of HTML/XML markup. The
browser's job is to turn that markup into a Web page so that you can see text, input
devices, pictures, tables, and so on in your browser window. It is also the browser's job
to store its interpretation of the HTML page as a model, called the Document Object
Model. The model is similar to the structure of a family tree, consisting of parents, chil-
dren, siblings, and so on. Each element of the tree is related to another element in the
5. ECMAScript 5th edition adds some new features and is now available for review and testing (2009).
Search WWH ::

Custom Search