Chapter 11. Back to the Browser

 

This chapter covers

  • Getting to grips with the Document Object Model
  • Working with the DOM using Prototype
  • Developing with HTML Forms using Prototype

We’ve spent several happy chapters exploring the workings of the JavaScript language. Now it’s time to remind ourselves that we’re using JavaScript to develop web applications. All of our lovely code is going to be running inside a web browser, and that means we’ll be using the browser-specific features of the JavaScript interpreter to get things done.

We’ve already seen in part 2 of the book how Scriptaculous can provide us with a lot of browser user interface (UI) elements out of the box. However, there are times when we’ll want to manipulate the browser UI at a lower level. The standard way of interacting with the page contents is through the Document Object Model, or DOM. Scripting the DOM is notoriously verbose and tedious, but fortunately the Prototype library provides a number of helpers to make things easier.

In this chapter, we’ll look at how Prototype helps us to work with the browser, rather than struggling against it. But first, we’ll cover a few of the basic DOM methods, to help us see where Prototype’s extensions are coming from.

11.1. A crash course in DOM methods

11.2. Prototype and the DOM

11.3. Extending the Event object

11.4. Working with HTML forms

11.5. Summary