As you’ve learned and worked with ASP, you’ve come to depend on the server object model documentation a lot to answer many queries. When do we need the properties of the
object? Where is that Server
collection? Is it the Cookies
object, the Response
object, or both? The object model provided by ASP is how we interface with the server, and it’s of utmost importance. Request
As you might expect, on the client-side, the browser object model is just as important. All of the interactions between our code and the browser take place via the object model, and without a good knowledge of how it is set up, our code either won’t work as well as it could, or it won’t work at all!
For the rest of this chapter, we’ll be covering the different objects in the browser object model, explaining how they relate to each other, and showing you some more examples. We need to understand exactly why we have to say things like
.Document.frmTest.txtURL.Value
In the ASP object model, there are five main objects:
, Server
, Response
, Request
, and Session
. These top-level objects have properties, methods, and subordinate objects where appropriate. Although it’s set up a bit differently, the browser object model follows the same principle of providing access to the features of the browser. Instead of five separate objects, the browser has one top level object called Application
. The rest of the browser’s objects are located beneath the Window
object in a logical hierarchy of functionality.Window
The
object represents the browser itself. It has a number of self-contained properties, like Window
(the current text of the status bar at the bottom of the browser) that reflect and provide access to the browser. Its methods perform operations that make sense for the browser window, like opening another window and navigating to a new page. And, last but not least, it fires events every time it finishes loading a page, or completes unloading a page in preparation for moving to a new URL or shutting down.status
To script programmers, the
object’s subordinate objects are just as interesting as its immediate properties, methods, and events.
Window
Document
object: represents the document currently displayed Frames
collection: represents the frames in the current window History
object: represents the history list of the browser Location
object: represents the current URL that the browser is displaying Navigator
object: represents information about the browser itself, like the version number*** Insert diagram from 0448 VBScript Page 148 - the object model.
*** Annotate: ' Each frame is in effect a window object ' (as in VBScript book).
Of these objects, the
object is by far the most utilized by the average script developer. It provides access to objects in the page currently displayed in the browser with the Document
, Link
, and Anchor
collections. If we think back to our previous series of Hello World examples, we’ll realize that we’ve been using the Form
collection of the Forms
object from the beginning of this chapter.Document
The rest of this section covers each of these elements in a bit more detail, focusing especially on the
and Window
objects. Document
Covering every last aspect of the scripting object model would occupy many chapters (and indeed does in many books about client-side scripting). In this chapter we’ll give an overview and cover the most important elements. For more information, please check out the Wrox Press book Instant VBScript, and the Scripting Object Model document available from Microsoft's Web site at
(search for http://www.microsoft.com
).scriptom
Since the
object is the root of many useful objects in the object model, we’ll start by looking at it first.Window