Behaviors are the actions of users, and they happen when users do something on an object. For instance, behaviors happen when users move mouse on an image, click on a text, double-click on an image map etc. Behaviors do not exist in HTML code and they are existed in JavaScript. You can insert behaviors in Dreamweaver by the Behaviors panel, so you don't have to write JavaScript in order to add behaviors in your website. An image normally may have one or more behaviors. Behaviors vary from pictures to other attributes of a website such as browse bar etc. However, it is not necessary to define behaviors for substitution bars and browser bars, as they are already defined.
You can open the Behavior panel by the Window menu, and then the Behaviors option. You can also open it by pressing Shift+F3. In the Behavior panel, you have to click on the <!--[if !vml]--><!--[endif]--> button, and in Show events for choosing a version from the browser. Some behaviors work with only particular browsers.
Many behaviors work only for Inter Explorer, while they don't work for Netscape. That is because majority of users are using Internet Explorer. You can select the behavior according to your choice and after the selection of browser; there is no need to re-select it later at the time of inserting behavior.
Inserting a behavior
You can insert behaviors in an established browser. The first thing that you have to do is to select the object on which the behavior will be implied. That object could be anything such as image and a text fragment etc. When you click on the <!--[if !vml]--><!--[endif]--> button of Behavior panel, Show Events for option will be displayed. Plus, a list containing previously selected behaviors will be displayed from which you could select one. Selection of behavior depends on the elements on which you want to apply the behaviors. It depends on you which actions do you select and which don't.
You cannot select the Validate form action in such a case when there are no forms in the Page. The corresponding behavior appears on the Behavior panel hen you select any action. In such case, two behaviors are inserted. Each behavior has an action and an event that is linked to it. Actions are those practices that you have selected in the previous list, and actions are defined by the events after their completion.
If you want to clear the behaviors, then select undesired behaviors in the Behaviors panel and click the <!--[if !vml]--><!--[endif]-->button. The orders of behavior also depend on you, if you want to change them then select them and arrange their order via <!--[if !vml]--><!--[endif]--><!--[if !vml]--><!--[endif]-->buttons.
Show and Hide Behaviors of layer
The most frequently used and interesting behavior is Show and Hide layers. In order to insert this behavior, you need to have layers in the relevant document. You are required to select an action from the list by clicking on the <!--[if !vml]--><!--[endif]--> button after choosing the image. In such a case, the action should be Show-Hide layers.
You have to specify the layer that you want to display and that you don't want to hide for the event, you have to do this after selecting the action. To do so, you are required to double clicking on the action in the Behavior panel. A new window ill then appear containing the roster of all the layers in the page. You can identify the view variation for every layer.
You can signify if these layers are going to be displayed, Hidden, or Predetermined. In order to designate the state of each layer, it is important to choose them in a sequential order, and indicate the state through the buttons at the base of the window.
It is not important to imply different view to all layers of a same page. For instance, in such case the "canmonth" layer has not been changed for a different view that is because we want to be the same at the time of the displaying of event. To clear the view of an already established layer of any page, click on the button of applied view. For instance, to clear the view applied to the "catweek" layer, you would have to click on the Show tab. You have to be specific according to your requirements. A layer is shown when you place the cursor on an image, and it suddenly becomes invisible when you off the cursor from it. For such a case, you need to add two Show-Hide layers behaviors with the action. One of these will display the layer for the event onMouseOver, whereas, other will make it invisible for the event onMouseOut. In the former event the mouse is over, while in the latter, the mouse is out.
Using JavaScript Code
Call JavaScript is another type of behavior. This behavior let you add JavaScript code inside the file. For instance, you can make it possible to close the browser window by clicking on an object. To perform it, you need to add a "window.close();" JavaScript line. It is similar to the examples of the layers, the first step is to choose an object on which you want to apply this behavior. The second step is to choose the Call JavaScript action via the <!--[if !vml]--><!--[endif]--> button. A new window will be opened in which you will have to introduce the JavaScript line.
Once you have inserted in the Behavior panel, you have to establish an onclick event to generate the Call to JavaScript that becomes active when you click on the object. You can re-open the previous window by double clicking on the action, after opening it you can modify the line code.