Using Behaviors

Using behaviors is an easy three-step process:

  1. Decide what action you want to take (such as whether to validate the user’s data entry or pop up a new window).

  2. Decide when you want to take the action (such as when the user selects an item from a menu).

  3. Decide where you want to look for the event (i.e., to which element you want to attach the behavior).

The action that you want to take dictates which behavior you’ll use. You’ll often want to react to user activities, such as mouseclicks, keyboard entry, or resizing the browser. These and other events can be used to trigger actions; the browser will run the chosen behavior automatically when the designated event occurs.

You must decide where to apply a behavior in order to limit its scope to the events you are interested in. For example, you might take some action when the user clicks on a button, but you might ignore mouseclicks elsewhere. Therefore, you’ll attach your behaviors to HTML elements, such as images, buttons, text, or the body tag. Sometimes a behavior applied to one tag influences another HTML element. For example, a behavior applied to a checkbox could be used to change the properties of another element or to update the contents of a frame.

You’ll typically configure a behavior’s parameters using Dreamweaver’s friendly UI. For example, when using the Open Browser Window behavior you’ll specify parameters for the window’s height and width (see Figure 12-11).

There you have it! Just attach a behavior (action) ...

Get Dreamweaver in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.