Chapter 19. Behaviors

Team-Fly    

Macromedia® DreamWeaver® MX Unleashed
By Matthew Pizzi, Zak Ruvalcaba
Table of Contents
Part V.  Behaviors and Middleware


by Matthew Pizzi

IN THIS CHAPTER

  • Attaching Behaviors

  • Calling JavaScript

  • Change Property

  • Check Browser

  • Check Plug-In

  • Drag Layer

  • Go to URL

  • Jump Menu

  • Play Sound

  • Pop-Up Message

  • Preload Images

  • Set Nav Bar Image

  • Set Text

  • Show-Hide Layers

  • Show Pop-Out Menu

  • Swap Image/Swap Image Restore

  • Validate Form

In many cases, you may want to add functionality to your Web page. Often, Web developers will use the famous pop-out window or even make layers appear and disappear. What's great about these behaviors is that Dreamweaver writes all the JavaScript to make these behaviors happen. This can be a tremendous help to those not wanting to learn JavaScript and a time-saver for those who do know it.

What's important to know about behaviors is that they're canned JavaScript snippets of code. They do what they do nothing more and nothing less. If you know JavaScript, you can modify and tweak to your heart's content; however, if you don't know JavaScript, this may be a source of frustration for you.

For the most part, the behaviors available to you are practical for real-world applications. You might find that you want to accomplish something that isn't offered by the behaviors and will be forced to write the JavaScript yourself. If you find that there is quite a bit you want to accomplish and there is no way to do it through the Behaviors panel, learning JavaScript may be a worthwhile investment.

Before you jump to any conclusions about the value of behaviors, let's take a look in detail at what they really have to offer. To open the Behaviors panel, choose Window, Behaviors.

Something you should know about behaviors is they have to be applied to a specified <tag>. Whether it's the <body> or <a> anchor tag, it must be attached to some form of an HTML tag. Which tag you should attach the behavior to depends on what your desired effect is, in terms of how the behavior is triggered.

As shown in Figure 19.1, you also have to specify a target browser when applying a behavior. Your best bet, in terms of options and compatibility, is to choose 4.0 or Later Browsers. This offers a broader range of events to activate the JavaScript, or behavior. If you choose 3.0 Browsers, the results between different browsers and different operating systems are unpredictable.

Figure 19.1. Notice all the different events when 4.0 or Later Browser is selected in the Event drop-down menu of the Behaviors panel.

graphics/19fig01.gif

By choosing 4.0 and Later Browsers, you ensure compatibility with the majority of the Web audience. However, the behaviors are still a bit finicky when you're trying to achieve complete cross-browser and cross-platform compatibility.

If you refer to Figure 19.2, you'll note all the different behaviors available to you. You can even build your own or download additional behaviors from the Macromedia Exchange. As I mentioned earlier, if there's something specific you want to perform and you don't want to invest the time in learning JavaScript, you may have some luck on the Exchange, located at http://www.macromedia.com/dreamweaver/exchange.

Figure 19.2. Different behaviors that ship with Dreamweaver MX can add functionality to your Web pages.

graphics/19fig02.gif

You'll notice that some of the behaviors are grayed out and not available. The reason for that is you don't have the proper content, either on the document or selected, as you click the plus sign button to see the behaviors. Some behaviors can be attached, or applied, only to specific tags.


    Team-Fly    
    Top


    Macromedia Dreamweaver MX Unleashed
    Macromedia Dreamweaver MX 2004 Unleashed
    ISBN: 0672326310
    EAN: 2147483647
    Year: 2002
    Pages: 321

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