O'Reilly logo

JavaScript® Bible, Sixth Edition by Danny Goodman, Brendan Eich, Michael Morrison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Window and Document Objects

IN THIS CHAPTER

  • What the window object does

  • How to access key window object properties and methods

  • How to trigger script actions after a document loads

  • The purposes of the location and navigator objects

  • How the document object is created

  • How to access key document object properties and methods

Now that you have exposure to programming fundamentals, it is easier to demonstrate how to script objects in documents. Starting with this lesson, the tutorial turns back to the document object model (DOM), diving more deeply into objects you will place in many of your documents.

Top-Level Objects

As a refresher, study the hierarchy of top-level objects in Figure 8-1. This chapter focuses on objects of this level that you'll frequently encounter in your scripting: window, location, navigator, and document. The goal is not only to equip you with the basics so you can script simple tasks, but also to prepare you for in-depth examinations of each object and its properties, methods, and event handlers in Part III of this book. I introduce only the basic properties, methods, and events for objects in this tutorial; you can find far more in Part III. Examples in that part of the book assume that you know the programming fundamentals covered here in Part II.

The top-level browser object model for all scriptable browsers.

Figure 8-1. The top-level browser object model for all scriptable browsers.

The window Object

At the top of the object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required