Dreamweaver Behaviors

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:

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:

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.

Null Link Status Bar Message

Status Bar Message when a page loads.

This is basically the same principal used above, but you will apply it to the body tag in your document window.

Popup Menus

Follow these steps to create a popup window:

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 (lower left corner) before setting your behavior and follow the same steps as above.

Swap Image

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

This can be done quite easily:

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 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.

Jump Menu

A jump menu is a pop-up menu in a document, visible to your site visitors, listing options that link to documents or files. With jump menus you can create links to documents in your Web site, links to documents on other Web sites, e-mail links, links to graphics, or links to any file type that can be opened in a browser. When you create a jump menu by using Insert > Form Objects > Jump Menu, Dreamweaver creates a menu object and attaches the Jump Menu (or Jump Menu Go) behavior to it. There is usually no need to attach the Jump Menu action to an object by hand.

To create a jump menu:

Select the Select First Item After URL Change option, then click the plus (+) button to add the selection prompt to the menu.

Once you've created your jump menu, you can edit it in either of two ways:

To edit a jump menu using the Behaviors panel:

Check Plugin

Use the Check Plugin action to send visitors to different pages depending on whether they have the specified plugin installed. For example, you might want visitors to go to one page if they have Shockwave and another page if they do not.

Note: You cannot detect specific plugins in Microsoft Internet Explorer using JavaScript. However, selecting Flash or Director in the Check Plugin dialog box will add the appropriate JavaScript code to your page to detect those plugins in Internet Explorer in Windows. Plugin detection is impossible in Internet Explorer on the Macintosh.

To use the Check Plugin action:

In general, if the plugin content is integral to your page, select the "Always go to first URL if detection is not possible" option; visitors without the plugin will often be prompted by the browser to download the plugin. If the plugin content is not essential to your page, leave this option unselected.

If the events you want are not listed, change the target browser in the Show Events For pop-up menu.

Show/Hide Layers

The show/hide feature presented here will be names in the form of links that when you place your cursor over the word will show the image. Example: I have the word apple on the page and when I place the cursor over the word 'apple,' the image of an apple will appear on the page.

Here is an example of a layer created with four named links:

Don't worry about the size of the layer or the positioning for now. We'll clean that up soon enough.

You can also resize the layer to the size of the image numerically. Click once on the image and then go up to the Properties Inspector and in the image properties, note the width/height and input the values in the W and H fields (Width and Height).