• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Hour 17. Adding Interactivity with Behaviors > What Is a Dreamweaver Behavior?

What Is a Dreamweaver Behavior?

When you add a behavior to a web page, Dreamweaver inserts JavaScript functions and function calls, enabling users to interact with the web page or make something happen. I like to think of a function as a little code machine—you send it some information, it processes it, and it sends you a result or makes something happen. A function call is the code added to an object that triggers the function and sends it any information it needs to do its job. For instance, a popular Dreamweaver behavior is the Swap Image behavior you used in Hour 7, “Displaying Images.”

When you insert a behavior, Dreamweaver writes a function in the head of the web page. The function that controls the Swap Image behavior is called MM_swapImage(). The code in that function isn't called until some event on the page triggers it; until it's triggered the function code just sits waiting in the head. For instance, the MM_swapImage() function is usually triggered by the onMouseOver event—the event fired when the cursor is placed over whatever object to which the function is attached. When the user rolls her mouse over an image with a behavior attached, the event triggers the function which swaps the image source with another image.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint