Skip to main content

Browser Object Model Components

What Is an Object?

Only the simplest JavaScript programs will do nothing but assign values to variables and calculate expressions. To go beyond these basic script beginnings-that is, to write truly useful scripts-you have to do what JavaScript was designed to do from the start: Manipulate the Web browser and the page that it's displaying. That's what JavaScript is all about, and that manipulation can come in many different forms:

  1. Open a new browser window to display a different page.
  2. Change the page that's displayed within a frame.
  3. Send the browser to a new location.
  4. Write text to the currently displayed document.
  5. Validate a form's data before submitting it.

The bold items in this list are examples of the "things" that you can work with, and they're special for no other reason than they're programmable. In JavaScript parlance, these "programmable things" are called objects.

You can manipulate objects in JavaScript in any of three ways:

  1. You can make changes to the object's properties.
  2. You can make the object perform a task by activating a method associated with the object.
  3. You can define a procedure that runs whenever a particular event happens to the object.

Next: Browser-Specific Objects in Client-based Scripts