• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. Handling the Browser Environment

Chapter 4. Handling the Browser Environment


In this chapter, we’re going to start putting JavaScript to work where it was designed to be used: in browsers. That means we’re going to start interacting with browsers using the various browser objects available to us in JavaScript, such as the window, document, and navigator objects. This chapter will provide us with an in-depth overview of not only those objects, but also the different object models available in various browsers and versions. We’ll need that information in coming chapters.

Now that we’re working with browsers, we’ll also consider how to handle cross-browser programming issues, discussing how to determine what browser your script is executing in, and how to determine what objects are available to you.

Tip

In this book, it’s not necessary to memorize which browser has which object model and try to guess whether your script will work as you plan. Instead, when you look up a language element or object property, method, or event here, you’ll find a table showing directly which browser, and which browser version, supports that item. All you need to know is what browser and browser version you’re working with, and you’ll see how to determine that in this chapter.


We’ll also take a look at how to access not only the big Document Object Model (DOM) objects, such as the window and navigator objects, but also all the HTML elements in a web page. In JavaScript, those HTML elements are represented as objects, and you’ll see the many ways of accessing those elements in your scripts.

I’ll start this chapter now by taking a look at the history of the various DOMs of various browsers.

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint