Chapter 16: behaviors, How behaviors work – Adobe Extending Dreamweaver CS4 User Manual
Page 240
234
Chapter 16: Behaviors
The term behavior refers to the combination of an event and an action.
onClick
,
onLoad
, and
onSubmit
are examples
of events. Check Plug-in, Go to URL, and Swap Image are examples of actions. The browser determines which HTML
elements accept which events. Files that list events that each browser supports are stored in the
Configuration/Behaviors/Events folder within the Adobe Dreamweaver application folder.
The body section of an Action file generally contains an HTML form. The HTML form accepts parameters for the
action (for example, parameters that indicate which absolutely positioned elements to display or hide). The head
section of an Action file contains JavaScript functions that process form input from the body content. They also control
the functions, arguments, and event handlers that are inserted into the document of a user.
Write behavior actions when you want to share functions with users or when you want to insert the same JavaScript
function repeatedly. Ensure that you change the parameters each time.
Note: You cannot use behaviors to insert VBScript functions directly. However, you can add a VBScript function
indirectly by editing the Document Object Model (DOM) in the
applyBehavior()
function.
The following table lists the files you use to create behavior actions:
Note: For information about server behaviors that provide web application functionality, see “
How Behaviors work
When a user selects an HTML element in a Dreamweaver document and clicks the Plus (+) button on the Behaviors
panel, the following events occur:
1
Dreamweaver calls the
canAcceptBehavior()
function in each Action file to see whether this action is appropriate
for the document or the selected element.
If the return value of this function is
false
, Dreamweaver dims the action in the Actions pop-up menu. (For
example, the Control Shockwave action is dimmed when the user’s document has no SWF files.) If the return value
is a list of events, Dreamweaver compares each event with the valid events for the currently selected HTML element
and target browser until it finds a match. Dreamweaver populates the Events pop-up menu with the matched event
from the
canAcceptBehavior()
function at the top of the list. If no match exists, the default event for the HTML
element (marked in the Event file with an asterisk [*]) becomes the top item. The remaining events in the menu are
assembled from the Event file.
2
The user selects an action from the Actions pop-up menu.
3
Dreamweaver calls the
windowDimensions()
function to determine the size of the Parameters dialog box. If the
windowDimensions()
function is not defined, the size is determined automatically.
A dialog box always appears, with OK and Cancel buttons at the right edge, regardless of the contents of the
body
element.
Path
File
Description
Configuration/Behaviors/Actions/
behavior action.htm
The body of the file contains an HTML form for the
parameters of the action. The head of the file
contains the JavaScript functions.