Page 119 - DCAP202_Fundamentals of Web Programming
P. 119
Fundamentals of Web Programming
Notes
Did u know? The Level 1 DOM HTML specification defines additional functionality needed
for HTML documents.
9.1.1 Objects of Desire
The objects are self-contained bundles of data. Variables associated with an object are called
properties of the object. Functions that can be executed by an object are called methods of the
object.
There are three kinds of objects in JavaScript:
User-defined objects created from scratch by the programmer.
Native objects like Array, Math, and Date, which are built in to JavaScript.
Host objects that are provided by the browser.
From the earliest days of JavaScript, some very important host objects have been made available
for scripting. The most fundamental of these is the window object.
The window object is nothing less than a representation of the browser window itself. The
properties and methods of the window object are often referred to as the Browser Object Model
(although perhaps Window Object Model would be more semantically correct).
The Browser Object Model has methods like window.open and window.blur. These methods,
incidentally,are responsible for all those annoying pop-up and pop-under windows that have
plagued the Web.
Fortunately, we won’t be dealing with the Browser Object Model very much. Instead, we’ll focus
on what’s inside the browser window. The object that handles the contents of a web page is the
document object. For the rest of this book, we’re going to be dealing almost exclusively with the
properties and methods of the document object.
9.1.2 Dial M for Model
The M in DOM stands for Model, but it could just as easily stand for Map. A model, like a map,
is a representation of something. A model train represents a real train. A street map of a city
represents the real city. The DOM represents the web page that’s currently loaded in the browser
window. The browser provides a map (or model) of the page. You can use JavaScript to read this
map.
Maps make use of conventions like direction, contours, and scale. In order to read a map, you
need to understand these conventions – and it’s the same with the DOM. The most important
convention used by the DOM is the representation of a document as a tree. More specifically, the
document is represented as a family tree.
In order to gain information from the model, you need to understand what conventions are
being used to represent the document.
Task Analyse the uses of Dial M for Model.
112 LOVELY PROFESSIONAL UNIVERSITY