Chapter 11. Windows and Frames

Up to this point I've focused mainly on foundational JavaScript programming topics — ones that apply to any ECMAScript runtime whether that happens to be in or outside a browser. Of course, what you're usually interested in when learning about JavaScript development is browser scripting. This is by far the most common use case for JavaScript — and certainly where all the fun stuff happens. In this chapter you'll revisit the browser, looking in particular at how you can interact with it on a high level. I'll discuss how to get basic browser and operating-system information, what you can do with the top-level browser objects, including window, navigator, location, history, and screen, and how to manipulate windows. Later, I'll discuss dealing with frames and dialogues and how to encode strings for URLs.

Overview of the Browser Object Model

There are essentially three distinct domains or components of browser scripting: core JavaScript, the Document Object Model (DOM), and the Browser Object Model (BOM). The first two have published specifications, but the BOM has evolved gradually over time without the benefit of a common design document among the various browser vendors. Fortunately, there is a fair amount of agreement among them, and you are left with an essentially uniform and lightweight interface for interacting with the browser itself at a very high level. In Chapter 1 I introduce the concept of the BOM as the way you interact with the various components ...

Get JavaScript® Programmer's Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.