Great Templates

FEATURED WEB TEMPLATES

Amazon Books

Learn PHP

PHP Training
Zend Cert Training Zend Certified Engineer Zend PHP Pro

Dreamweaver: Behaviors

Behaviors

In addition to page layout, Dreamweaver has the capacity to add interactivity to a page with the use of 'Behaviors'. This can be anything from controlling a Shockwave movie, to opening a browser window, to displaying a status bar message.

What are behaviors? They are Javascript events that are applied to a specific HTML tag. While you don't need to know Javascript in order to use them in Dreamweaver, it is a good idea to understand a little of how it works.

Javascript is called by certain events that happen during the browser session. The way to determine these events is with the use of Event Handlers, such as onClick or onMouseover. Dreamweaver uses these event handlers within the Behaviors Palette, and they are used to determine when the behavior will go into effect.

In this section you will learn how to use Dreamweaver Behaviors, how to apply them to specific HTML tags, and how to use some of the behaviors that are built in to Dreamweaver.


The Behaviors Palette

The Behaviors Palette is accessed from the Window Menu by selecting 'Behaviors', or by pressing F8 on the keyboard.

There are several components of the palette:

  1. + (plus): This brings up a submenu where a new behavior can be added.
  2. - (minus): This removes a behavior that already exists. This button is grayed out unless a behavior is selected.
  3. Events for: This menu allows you to select what browser compatibility you prefer for new behaviors. It is recommended that you leave this at '3.0 and Later Browsers', which is the default.
  4. Arrows: The up and down arrows will change the selection of existing behaviors above or below. These are grayed out unless there are at least 2 behaviors already.
  5. Events: This field is where the Event Handler name is displayed.
  6. Actions: This is the name of the behavior that will execute.

Creating a Behavior

To create a behavior, you must first decide which HTML tag it will be applied to. This decision will depend on the type of behavior you would like to add. Once you have decided on the tag, you must select it. This can be done by placing the cursor within the element on your page, or by selecting from the Tag list at the bottom:

Once you have selected the tag, click on the + button on the Behaviors Palette. This will bring up a list of the Behaviors available to Dreamweaver. Click on the one you wish to use, and a dialog box will come up. The dialog box varies depending on the Behavior you wish to use.

Once the Behavior has been created, it will appear in the Behaviors Palette.

You can now modify the Action of the Behavior by double clicking on the text within the Action field. For the above example, that text would be 'Go To URL'. This will bring up the same dialog box with the information already filled in.

You can also change the Event that will trigger the Behavior. We will now talk about the different events that can be used and when to use them.

Behavior Events

There are several events that can trigger your Behaviors. There is a complete listing in the Dreamweaver Help section. Here are a few of the more common events:

  • onBlur: This is when an element loses focus.
  • onChange: When a value is changed on the page.
  • onClick: When the element is clicked.
  • onLoad: When the page or element finished loading.
  • onMouseDown: When the user presses a mouse button.
  • onMouseOut: When the mouse is moved away from the element.
  • onMouseOver: When the mouse is moved over an element.
  • onReset: When a form is reset.
  • onSelect: When text in a text field is selected.
  • onSubmit: When a form is submitted.
  • onUnload: When the page is left.

To change the Event, highlight the existing event by clicking once, then bring down the menu that will give you a list of other available events.

Status Bar Messages

A status bar message is a custom message that appears on the lower left corner of the browser. This usually happens during an onMouseover event. These are probably the easiest Behaviors to create in Dreamweaver.

Follow these steps to create a status bar message:

  1. Create a link. This can be a text or image link.
  2. Select the link (the <a> tag).
  3. Open the Behaviors Palette.
  4. Click on the Behaviors Menu and click on 'Set Text', which will bring up another menu where you should choose 'Set Text of Status Bar'.
  5. A dialog box will come up with one field titled 'Message'. Simply type the message that you would like to appear and you're done.

Well, almost done. You don't want that message to display the entire time someone is at your page, do you? If not, you need to create an onMouseOut message. To do this, simply follow the above steps, but instead of a message hit the space bar once. Then select the new Behavior in the Palette, and change the event from onMouseOver to onMouseOut.

Popup Windows

You can also create a Popup Window with Behaviors in Dreamweaver.

Follow these steps to create a popup window:

  • Create a link. This can be a text or image link.
  • Select the link (the <a> tag).
  • Open the Behaviors Palette.
  • Click on the Behaviors Menu and click on 'Open Browser Window'.
  • A dialog box will come up with several fields. The most important field is the 'URL to Display'. You can browse for a file if necessary. You can also specify the width and height of the window, whether it has a navigation toolbar, scrolling bars, etc. You can also give the window a name, which is useful if you plan on loading other information in there later.
  • Make sure the Event is set to onClick.

This can also be used with other events, such as onMouseOver or onLoad. If you would like to have a browser window open when a page is loaded, simply select the <body> (lower left corner) before setting your behavior and follow the same steps as above.

Swap Image

This effect has been called many times, such as Mouseovers, Rollovers, and more. Dreamweaver can accomplish this with the Swap Image behavior.

This can be done quite easily:

  • Insert an image.
  • Select the image (the <img> tag).
  • Name the image in the Properties Palette.
  • Open the Behaviors Palette.
  • Click on the Behaviors Menu and click on 'Swap Image'.
  • A dialog box will come up that lists all the images on the page. Make sure the name you gave this image is selected.
  • Enter the path or browse for the image to be used when it is moused over.

There are also two checkboxes that ask if you want to Preload images and Restore onMouseout. It is recommend that you check both of these. You can also preload several images at one time by using the Preload Behavior while the <body> tag is selected. If you are using multiple or complex mouseover effects, you can select Restore on Mouseout manually by using the original image as the source and using the onMouseout event.

 


 


Learn PHP | Zend Certified Engineer | Zend PHP Pro | PHP Web Apps | Web Hosting Service | Low Cost Domain Names | Great Templates | Great Books | Testimonials | Tech.Articles | TOS | AUS | Home | Linux Apache MySQL PHP