|
Developing Extensions for Macromedia Dreamweaver 8 Authors: Sandstrom A., Berry B. Published year: 2005 Pages: 83-84/282 |
| < Day Day Up > |
Chapter 14. BehaviorsBehaviors let users make their HTML pages interactive. They offer web designers an easy way to assign actions to page elements by filling in an HTML form. The term behavior refers to the combination of an event (such as onClick , onLoad , or onSubmit ) and an action (such as Check Plugin, Go to URL, Swap Image). 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 Macromedia Dreamweaver 8 application folder. Actions are the part of a behavior that you can control; when you write a behavior, you're really writing an Action file. Actions are HTML files. The BODY section of an Action file generally contains an HTML form that accepts parameters for the action (for example, parameters that indicate which layers to display or hide). The HEAD section of an Action file contains JavaScript functions that process form input from the BODY content and control the functions, arguments, and event handlers that are inserted into a user 's document. You should write behavior actions when you want to share functions with users or when you want to insert the same JavaScript function repeatedly, but 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 Chapter 15, "Server Behaviors," on page 321. |
| < Day Day Up > |
| < Day Day Up > |
How Behaviors workWhen a user selects an HTML element in a Dreamweaver document and clicks the Plus (+) button on the Behaviors panel, the following events occur:
Inserting multiple functions in the user's fileActions can insert multiple functions—the main behavior function plus any number of helper functions—into the HEAD section. Two or more behaviors can even share helper functions as long as the function definition is exactly the same in each Action file. One way of ensuring that shared functions are identical is to store each helper function in an external JavaScript file and insert it into the appropriate Action files using <SCRIPT SRC=" externalFile .js"> . When the user deletes a behavior, Dreamweaver attempts to remove any unused helper functions that are associated with the behavior. If other behaviors are using a helper function, it is not deleted. Because the algorithm for deleting helper functions errs on the side of caution, Dreamweaver might occasionally leave an unused function in the user's document. What to do when an action requires a return valueSometimes an event handler must have a return value (for example, onMouseOver="window.status='This is a link'; return true" ). But if Dreamweaver inserts the "return behaviorName(args)" action into the event handler, behaviors later in the list are skipped . To get around this limitation, set the document.MM_returnValue variable to the desired return value within the string that the behaviorFunction() function returns. This setting causes Dreamweaver to insert return document.MM_returnValue at the end of the list of actions in the event handler. For an example that uses the MM_returnValue variable, see the Validate Form.js file in the Configuration/Behaviors/Actions folder within the Dreamweaver application folder. |
| < Day Day Up > |
|
Developing Extensions for Macromedia Dreamweaver 8 Authors: Sandstrom A., Berry B. Published year: 2005 Pages: 83-84/282 |