Understanding Dreamweaver Behaviors

 < Day Day Up > 



Dreamweaver uses JavaScript to power the interactive operations of rollover buttons, navigation bars, and pop-up menus and all other Dreamweaver MX behaviors. A behavior is a combination of an event with an action triggered by that event. In the Behaviors panel, you add a behavior to a page by specifying an action and then, if needed, specifying an event that triggers that action. The action is a JavaScript function — an orderly declaration of specific variables and methods that allow the Web browser to track and manipulate various page objects. Dreamweaver behavior code is client-side JavaScript code; it is written to execute in the browser on the user's computer.

Behaviors can be attached to the document (the <body> tag) or to images, links, form objects, or other HTML elements.

About events

Events are messages that are generated by the browser when the Web visitor does something, such as click a link, load a Web page, or move the cursor over a rollover button. When the event for an object that has one or more behaviors attached occurs in the user's browser, the behavior's JavaScript function is called and the action is executed. Many possible events can be set to trigger Dreamweaver behaviors. Figure 40-1 shows the different browser options available from the Show Events For submenu accessed by pressing the Add (+) button in the Behaviors panel. The second option — 4.0 and Later Browsers — is the most versatile and ensures that your page is viewable in a large range of browsers.

click to expand
Figure 40-1: For greater browser compatibility, choose Show Events For ® 4.0 and Later Browsers.

When you apply all behavior, a default event is chosen. The type of event depends on the nature of the behavior and the object selected in the page. For example, when an image is selected, the event will read (onMouseOver). The parenthesis surrounding the event lets you know that this behavior is attached to an image's anchor href. You can change the event associated with the behavior by selecting the behavior attached to the object. When the downward arrow appears, click it to select a new event from the menu that appears.

Dreamweaver behavior functions

Dreamweaver behavior functions are written in the head of the HTML document, surrounded by script tags and comments, as follows:

<script language="JavaScript"> <! --  (behavior functions here) //--> </script>

The script tag tells the browser to use JavaScript. The comments hide the JavaScript from browsers that do not support it.



 < Day Day Up > 



Macromedia Studio MX Bible
Macromedia Studio MX Bible
ISBN: 0764525239
EAN: 2147483647
Year: 2003
Pages: 491

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net