Unit 13. Using behaviors (I)


In this unit we're going to learn the basic characteristics of the behaviors, and also look at a pair of examples of possible applications.

Introduction

 

behaviors are actions that happen when the userdoes something over an object, for example moving the mouse over an image, clicking on a text, double-clicking on an image map, etc.

behaviors don't exist as HTML code, they are programmed with JavaScript. Dreamweaver allows you to insert them through the Behaviors panel, so it is not necessary to write a JavaScript code line to program them.

The image below has a behavior associated. Place the mouse over it to see what happen.

 

 

The image has two behaviors associated to show and hide the layer. We'll look at this kind of behavior later.

Other behaviors you have seen are the ones applied to sustitution bars and browser bars, they are predefined, and for this reason it isn't necessary to introduce the set of behaviors through Behavior panel.

To validate forms you saw some of the caracteristics of Behavior panel. Let's remember which we need to insert behaviors later.

The Behavior panel can be opened through the Window menu, and then the Behaviors option, also by pressing Shift+F3.

In this panel you need to click on the button, and in Show events for selecting a version from the browser list.

Some behaviors don't work with some browsers. Depending on the selected browser, you will see or not some of the possible behaviors.

There are many behaviors for Internet Explorer but they don't work with Netscape. As most users use Internet Explorer, let's select this browser. You can select from one of its latest versions: IE 5.5 o IE 6.0.

Once the browser is selected it's not necessary to re-select it the following time you want to insert any behavior.

 

Inserting a behavior

 

When there is an established browser, you can insert behaviors.

The first thing to do is to select the object on which the behavior is going to be applied, it can be an image, a text fragment, etc.

When you click on the button of the Behavior panel you will see the Show Events for option. Also, you will see a list of all possible actions in the browser previously selected, so you can select one.

Depending on the element on which you want to apply the behaviuor, you can select some actions, and others not.

 

In this case the Validate form action cannot be selected because there isn't any form in the Page.

After choosing any action, the corresponding behavior appears in the Behaviors panel. In this case, two behaviors have been inserted.

As you can see, each behavior has an action and an event associated to it.

Actions are the ones which have been selected in the previous list, and the event indicates the action by itself (when it is done).

To clear any behavior, you need to select it in the Behaviors panel and click on the button. You can also change the order of the behaviors applied to an object, by selecting them and arranging their order through the buttons.

  Go to the previous page page Content  Go to the nex page  

Page 13.1