15. Working with Behaviors

Introduction

Everybody loves the versatility that JavaScript can bring to a Web page, yet not that many people love programming in JavaScript, to make it happen. Dreamweaver makes your life easier by allowing you to insert Behaviors, most of which directly translate into JavaScript. Using behaviors, you can do things like insert pop-up windows, create disjointed rollovers, check to see if users have a certain plug-in or what browser they’re running.

The best thing about behaviors and commands is that they are extendable. Many third party companies and individuals write commands and behaviors for Dreamweaver. You can download these extensions from the Web, most often for free!

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 specifying the event that triggers that action. Adobe Dreamweaver behaviors insert JavaScript code in documents to allow users to interact with a Web page, change the page, or to produce certain tasks. Behaviors are attached to a specific element on your page, whether it’s a text link, an image, and even certain HTML specific tags.

An action consists of pre-written JavaScript code that performs a specific task, such as opening a browser window, showing or hiding an AP element, playing a sound, or stopping a Flash movie. The actions provided with Dreamweaver are written by engineers to provide maximum cross-browser compatibility.

In this chapter you’ll learn how to apply behaviors to Web elements, how to edit and modify behaviors; even how to create and maintain a library of all your important behaviors.

Introducing Behaviors

Introducing Behaviors

DW 10.2

Dreamweaver helps non-programmer types (you know who you are) use built-in JavaScript functions that are useful to any Web project. The code generated is well optimized so you do not have to worry about performance. A Dreamweaver behavior consists of two parts: An action that instructs the browser what to do, and an event that triggers the specific actions.

Dreamweaver comes supplied with dozens of behavior actions, the most useful being:

Check Browser. The Check Browser action sends visitors to different pages depending on their specific browser.

Check Plug-in. The Check Plug-in action sends visitors to different pages depending on whether they have the specified plug-in installed.

Go To URL. The Go To URL action opens a new page in the current window or in the specified frame.

Open Browser Window. The Open Browser Window action opens a URL in a new window.

Play Sound. The Play Sound action plays a sound (requires the visitor to have the ability to play sounds).

Popup Message. The Popup Message action displays a JavaScript alert with the message you specify.

Preload Images. The Preload Images action loads images that do not appear on the page right away (i.e., rollover images) into the browser cache.

Show Pop-Up Menu. The Show Pop-Up Menu behavior creates a pop-up menu within a page.

Show/Hide Elements. The Show/Hide Elements action causes specified layers to be shown or hidden.

Swap Image. The Swap Image action creates button rollovers and other image effects (including swapping more than one image at a time).

Swap Image Restore. The Swap Image Restore action restores the last set of swapped images to their previous source files (automatically added whenever you attach the Swap Image action).

Validate Form. The Validate Form action checks the contents of selected text fields to ensure that the user has entered the correct type of data.

Note

Behavior code is client-side JavaScript code; that is, it runs in browsers, not on servers.

Behaviors are attached to a specific element on your page, whether it’s a text link, an image, and even certain HTML specific tags. After you attach a behavior to a page element, whenever the event you’ve specified occurs for that element, the browser calls the action (the JavaScript code) that you’ve associated with that event. (The events that you can use to trigger a given action vary from browser to browser.) For example, if you attach the Popup Message action to a link and specify that it will be triggered by the onMouseOver event, then whenever someone points to that link with the mouse pointer in the browser, your message pops up in a dialog box. A single event can trigger several different actions, and you can specify the order in which those actions occur.

In order to make a behavior work, an action is linked to an event. Events are, effectively, messages generated by browsers indicating that a visitor to your page has done something. For example, when a visitor moves the pointer over a link, the browser generates an onMouseOver event for that link; the browser then checks to see whether there’s some JavaScript code that the browser is to call when the event is generated. Different events are defined for different page elements; for example, in most browsers onMouseOver and onClick are events associated with links, where onLoad is an event associated with images and with the body section of the document. Notice the specific way that JavaScript code is written. It’s not only important to get the spelling of a code piece correct; in addition, case is important. For example onBlur is correct... onblur is not. The good news is that Dreamweaver inserts the correct code into the document through the use of the Behaviors panel.

The possible Events associated with an Action are:

onBlur. Activates when a blur event occurs. A field gains focus when the user clicks inside the text box, and the focus is lost (onblur) when the user clicks outside the box, anywhere on the page.

onClick. Activates when the user clicks the left mouse button on the object.

onDblClick. Activates when the user double-clicks the object.

onError. Activates when an error occurs during object loading.

onFocus. Activates when the object receives focus. A field gains focus when the user clicks inside the object.

onKeyDown. Activates when the user presses a key.

onKeyPress. Activates when the user presses an alphanumeric key.

onKeyUp. Activates when the user releases an alphanumeric key.

onLoad. Activates after the browser loads the object.

onMouseDown. Activates when the user clicks the object with either the mouse or a form button.

onMouseMove. Activates when the user moves the mouse over the object.

onMouseOut. Activates when the user moves the mouse pointer outside the boundaries of the object.

onMouseOver. Activates when the user moves the mouse pointer into the object.

onMouseUp. Activates when the user releases a mouse button while the mouse is over the object.

OnUnload. Activates immediately before the object is unloaded.

The target browser you select determines which events are supported for a given element. Internet Explorer 4.0, for example, has a much wider array of events for each element than Netscape Navigator 4.0 or any 3.0 browsers.

The power of Behaviors lies in the fact that they use JavaScript code to create dynamic and interactive Web pages. Although JavaScript is not new to Web page design, it’s quickly becoming more and more popular as the days roll by, and the World Wide Web Consortium (www.w3c.org) is working overtime to make all the code pieces work the same on all browsers. However, no matter how good the code is, there will always be times when the code warrior (you) decides that the code needs to be edited or completely eliminated. Thankfully, with Dreamweaver, this is no problem whatsoever.

Applying Behaviors to Page Elements

Applying Behaviors to Page Elements

DW 10.2

Dreamweaver allows you to attach behaviors to links, images, form elements, or any of several other HTML elements. The Behaviors panel allows you to attach, modify, and manage behaviors embedded in a page. In the Behaviors panel, you can use options to show all events for a specific category, or only the ones currently attached to the page. The target browser you select determines which events are supported for a given element. Dreamweaver works well with current browsers. However older ones may be more limited. Internet Explorer 4.0, for example, has a much wider array of events for each element than Netscape Navigator 4.0 or any 3.0 browsers. If you need additional functionality, you can attach more than one event to a specific action; for example, when you user clicks on a specific image, the image changes, and a prerecorded sound plays. When you use multiple actions, they occur in the order in which they’re listed in the Actions column of the Behaviors panel.

Apply One or More Behaviors to a Page Element

Apply One or More Behaviors to a Page Element Open the Web page you want to apply a behavior to an element.

Apply One or More Behaviors to a Page Element

Apply One or More Behaviors to a Page Element Click the Window menu, and then click Behaviors to display the Behaviors panel.

Apply One or More Behaviors to a Page Element Select an element (image or link) on the page in Design view.

Apply One or More Behaviors to a Page Element Click the Add Behavior button (plus sign), and then select a behavior action from the Actions menu.

Note

Actions dimmed in the menu can’t be chosen for that particular Web element.

Important

The Deprecated submenu provides features for those who used them in Dream-weaver 8 or earlier. Dreamweaver CS3 or later provides new ways to perform the same tasks.

Important Enter the parameters and options you want for the selected action; the parameters and options vary depending on the selected action.

Important

Important Click OK.

The action is embedded into the HTML code and appears in the Behaviors panel. The default event is onClick.

Important Click the default Event (onClick), and then click the Event list arrow to select the event you want to associate with this action (in this example, onMouseOver).

Important

Important If you want to apply more than one behavior, repeat steps 4-7.

Important Click the File menu, point to Preview In Browser, and then select a browser to test your Web page.

Important In your browser, perform the event to trigger the action.

Did You Know?

You can show events for a specific browser. Open the Behaviors panel, click the Add Behavior button, point to Show Events For, and then select the browser that you want to show events.

You can show all events or only the ones currently attached to the page. Open the Behaviors panel, click the Show All Events button to show all available events, or click the Show Set Events button to show only the events currently attached behaviors.

See Also

See “Checking for CSS Browser Compatibility” on page 234 for information on using browser compatibility.

Applying Behaviors to Entire Page

Applying Behaviors to Entire Page

DW 10.2

In addition to attaching behaviors to links, images, form elements, or any of several other HTML elements, you can also attach behaviors to an entire document (using the <body> tag). The process to apply a behavior to an entire page is similar to the one you use to attach a behavior to an individual page element. The difference is what you select. For a page element, you select the element; for an entire page, you select the <body> tag, which applies the behavior to the document. For example, you can use the Check Plug-in behavior to check for the existence of media players, such as Adobe Flash, Apple QuickTime, and Microsoft Windows Media Player, and then redirect a visitor.

Apply a Behavior to a Web Page

Apply a Behavior to a Web Page Open the Web page you want to apply a behavior to an entire page.

Apply a Behavior to a Web Page

Apply a Behavior to a Web Page Click the Window menu, and then click Behaviors to display the Behaviors panel.

Apply a Behavior to a Web Page Click the <body> tag in the tag selector at the bottom left of the Document window.

Apply a Behavior to a Web Page Click the Add Behavior button (plus sign), and then select a behavior action from the Actions menu.

Apply a Behavior to a Web Page Enter the parameters and options you want for the selected action; the parameters and options vary depending on the selected action.

Apply a Behavior to a Web Page Click OK.

Did You Know?

You can download and install third-party behaviors. If you don’t find the behavior functionality you need, you can download and install behaviors created by third-party developers. Open the Behaviors panel, click the Plus (+) button, and then click Get More Behaviors from the Actions menu. In your browser, search for the behavior you want on the Exchange site, and then download and install it according to the site instructions.

Apply the Check Plugin Behavior to a Web Page

Apply the Check Plugin Behavior to a Web Page Open the Web page you want to apply a behavior to an entire page.

Apply the Check Plugin Behavior to a Web Page

Apply the Check Plugin Behavior to a Web Page Click the Window menu, and then click Behaviors to display the Behaviors panel.

Apply the Check Plugin Behavior to a Web Page Click the <body> tag in the tag selector at the bottom left of the Document window.

Apply the Check Plugin Behavior to a Web Page Click the Add Behavior button (plus sign), and then click Check Plugin.

Apply the Check Plugin Behavior to a Web Page Select the following options from the Check Plugin dialog box.

Select. Click the Select option, and then select a plugin from the popup menu (in this example, Flash).

Select.

Enter. Click the Enter option, and then enter or browse for the name of the required plugin (use if your plugin is not displayed in the Select popup menu).

If Found Go To URL. Enter or browse for the name of the URL to go to, if the required plugin is found on the visitor’s computer.

Otherwise Go To URL. Enter or browse for the name of the URL to go to, if the plugin is not found on the visitor’s computer.

Always Go To First URL If Detection Is Not Possible. Select if the visitor’s computer does not allow for plugin checking, and the browser loads the first URL.

Always Go To First URL If Detection Is Not Possible. Click OK.

Editing Behaviors

After you create a behavior, you can quickly and easily change the parameters for the action or the event that triggers the action. When you complete your changes to a behavior, all occurrences of the behavior on the page are updated. If other pages use the same behavior, you need to update the behavior on each page.

Edit the Parameters for a Behavior

Edit the Parameters for a Behavior Open the Web page with the behavior you want to change.

Edit the Parameters for a Behavior

Edit the Parameters for a Behavior Click the Window menu, and then click Behaviors to display the Behaviors panel.

Edit the Parameters for a Behavior Select an element on the Web page that contains an attached behavior, or if the behavior is attached to the document, click the <body> tag in the tag selector at the bottom left of the Document window.

The behaviors attached to the element appear in the Behaviors panel.

Edit the Parameters for a Behavior Select the specific event for the action that you want to edit.

Edit the Parameters for a Behavior Click the Behaviors Options button, and then click Edit Behavior.

Timesaver

Double-click the event to open the dialog box; you can also select it, and then press Enter (Win) or Return (Mac).

Timesaver In a behaviors dialog box, make the changes you want; the dialog box options differ depending on the behavior.

Timesaver

Timesaver Click OK.

Change the Event for a Behavior

Change the Event for a Behavior Open the Web page with the behavior you want to change.

Change the Event for a Behavior

Change the Event for a Behavior Click the Window menu, and then click Behaviors to display the Behaviors panel.

Change the Event for a Behavior Select an element on the Web page that contains an attached behavior, or if the behavior is attached to the document, click the <body> tag in the tag selector at the bottom left of the Document window.

The behaviors attached to the element appear in the Behaviors panel.

Change the Event for a Behavior Click the specific event that you want to edit.

Change the Event for a Behavior Click the Event list arrow, and then select the event you want to trigger the action from the available options.

Working with Behaviors

Behaviors you have attached to a selected page element appear in the Behaviors panel in the behaviors list by event in alphabetical order. If you have multiple actions for a specific event, the behaviors are executed by the browser in the order in which they appear in the behavior list. You can use the Behaviors panel to change the order. If you no longer need a behavior, you can remove it from the list.

Change Multiple Behavior Order

Change Multiple Behavior Order Open the Web page with the behavior you want to change.

Change Multiple Behavior Order

Change Multiple Behavior Order Click the Window menu, and then click Behaviors to display the Behaviors panel.

Change Multiple Behavior Order Select an element on the page that contains multiple behaviors.

The behaviors attached to the element appear in the Behaviors panel.

Change Multiple Behavior Order Select the behavior action you want to change.

Change Multiple Behavior Order

Change Multiple Behavior Order Click the Up or Down buttons to move the action to a different stacking order.

Timesaver

Press the Up and Down arrow keys to move the selected action.

Remove a Behavior

Remove a Behavior Open the Web page with the behavior you want to remove.

Remove a Behavior

Remove a Behavior Click the Window menu, and then click Behaviors to display the Behaviors panel.

Remove a Behavior Select an element on the Web page that contains an attached behavior, or if the behavior is attached to the document, click the <body> tag in the tag selector at the bottom left of the Document window.

The behaviors attached to the element appear in the Behaviors panel.

Remove a Behavior Select the behavior action you want to delete.

Remove a Behavior

Remove a Behavior Click the Remove Event button (minus sign).

The behavior is removed from the document.

Adding Behavior Effects

Dreamweaver Effects give you one more way to create dynamic Web pages. For example, you can use Behavior Effects to make a Web element shrink to half size, or to slowly fade away, there’s even an event that lets you make objects shake. While these options are fun to use, remember that Web design is not about what you can do to a site to make it dynamic. You have to ask yourself this question: Are the special effects that I’m using helping me to keep my visitor’s attention, and are they in line with the message that I’m trying to send? If the answer to those questions is “yes,” then by all means, use effects; however, if the answer is “no,” then stay away from using the effects.

Adding Effects

Adding Effects Open the Web page you want to apply a behavior effect to an element.

Adding Effects

Adding Effects Click the Window menu, and then click Behaviors to display the Behaviors panel.

Adding Effects Select an element on the page to which you want to attach an effect.

Adding Effects Click the Add Behavior button (plus sign), point to Effects, and then select an effect from the following options:

Appear/Fade. Use this effect when you want the element to slowly appear or fade from the Web page.

Blind. Use this effect when you want the element to slowly rise or lower on the page (like opening or closing a blind).

Grow/Shrink. Use this effect when you want the element to increase or decrease in size.

Highlight. Use this effect when you want the element (typically text) to change color.

Shake. Use this effect when you want the element to shake side to side.

Slide. Use this effect when you want the element to slide. Works by selecting the container tag of the content tag that you want to slide.

Squish. Use this effect when you want the element to slowly reduce in size until gone (the anchor point for the squish effect is the upper-left corner of the Web object).

Squish. Specify the options you want in the dialog box for the specific effect; the options vary depending on the effect.

Important

Not all the behavior effects work for all the elements in Dreamweaver; an error message may appear.

Important
Important

Important Click OK to attach the effect to the Page, Document, or Tag.

Going to Another Web Page

The Go To URL behavior gives you the ability to link an element on a Web page to a URL address. For example, you can create a Web page, and then use the Go To URL behavior to direct visitors to other sites and pages, or you can create a set of interactive buttons for use on a standard HTML driven Web site. Whichever option you choose, the ability to direct a visitor to other Web sites is essential to creating Internet-oriented documents.

Use the Go To URL Behavior

Use the Go To URL Behavior Open the Web page you want to apply a behavior.

Use the Go To URL Behavior

Use the Go To URL Behavior Click the Window menu, and then click Behaviors to display the Behaviors panel.

Use the Go To URL Behavior Click the element you want to add the Go To URL behavior.

Use the Go To URL Behavior Click the Add Behavior button (plus sign), and then click Go To URL.

A dialog box appears, allowing you to set the details of the action.

Use the Go To URL Behavior Type the URL or click Browse, select the URL from the Select File dialog box, and then click OK.

Use the Go To URL Behavior

Use the Go To URL Behavior Click OK.

Use the Go To URL Behavior To change the trigger, click the event, click the Event list arrow, and then select the event you want.

Opening Another Browser Window

The Open Browser behavior allows you to set a hyperlink to open in a new browser window. When you use the Open Browser behavior, you need to specify the URL you want to open in the new browser window and any window attributes, such as width, height, navigation and location toolbar, status bar, menu bar, scrollbar as needed and resize handles. If you want to use this behavior with text, you can also use the Change Property and Change Property Restore behaviors to change the pointer to a hand when visitors hover over your text link.

Open Another Browser Window

Open Another Browser Window Open the Web page you want to apply a behavior.

Open Another Browser Window

Open Another Browser Window Click the Window menu, and then click Behaviors to display the Behaviors panel.

Open Another Browser Window Click the element you want to add the Open Browser Window behavior; typically link text or graphic.

Open Another Browser Window Click the Add Behavior button (plus sign), and then click Open Browser Window.

A dialog box appears, allowing you to set the details of the action.

Open Another Browser Window Type the URL or click Browse, select the URL from the Select File dialog box, and then click OK.

Open Another Browser Window

Open Another Browser Window Enter a window size (width and height in pixels).

Open Another Browser Window Select the check boxes with the window attributes you want to use.

Open Another Browser Window Enter a window name. The window name is used in the behavior script, so it cannot have any spaces or special characters.

Open Another Browser Window Click OK.

Open Another Browser Window To change the trigger, click the event, click the Event list arrow, and then select the event you want.

Displaying Text Messages

Dreamweaver provides several behaviors to display user text messages, including Popup Message and Set Text. The Set Text behavior consists of four individual behaviors: Set Text of Container, Set Text of Frame, Set Text of Status Bar, and Set Text of Text Field. These behaviors allow you to display text in an alert dialog box, a container, specific frame, text field, or the Status bar.

Create a Popup Message Window

Create a Popup Message Window Open the Web page you want to apply a behavior.

Create a Popup Message Window

Create a Popup Message Window Click the Window menu, and then click Behaviors to display the Behaviors panel.

Create a Popup Message Window Click the element you want to add the Popup Message behavior.

Create a Popup Message Window Click the Add Behavior button (plus sign), and then click Popup Message.

A dialog box appears, allowing you to set the details of the action.

Create a Popup Message Window Type the message you want.

Create a Popup Message Window

Create a Popup Message Window Click OK.

Create a Popup Message Window To change the trigger, click the event, click the Event list arrow, and then select the event you want.

Create a Status Bar Message

Create a Status Bar Message Open the Web page you want to apply a behavior.

Create a Status Bar Message

Create a Status Bar Message Click the Window menu, and then click Behaviors to display the Behaviors panel.

Create a Status Bar Message Click the element you want to add a behavior.

Create a Status Bar Message Click the Add Behavior button (plus sign), point to Set Text, and then click Set Text Of Status Bar.

A dialog box appears, allowing you to set the details of the action.

Create a Status Bar Message Type the message you want.

Create a Status Bar Message

Create a Status Bar Message Click OK.

Create a Status Bar Message To change the trigger, click the event, click the Event list arrow, and then select the event you want.

Preloading and Swapping Images

The Preload Images behavior allows you to preload images when a Web page initially loads. This is useful when you want to swap images on mouse rollover buttons. The Preload Images behavior loads the rollover image when the page initially loads, so visitors will not experience a delay while the image loads the first time a visitor points to the button. The Swap Images behavior allows you to swap one image for another when an event occurs. The most common use of this behavior is to create rollover buttons. Along with the Swap Image behavior, you can also use the Swap Image Restore behavior, which restores the images that were swapped by the Swap Image behavior.

Preload Images

Preload Images Open the Web page you want to apply a behavior.

Preload Images

Preload Images Click the Window menu, and then click Behaviors to display the Behaviors panel.

Preload Images Click the element or <body> tag in the tag selector for the entire page you want to add the Preload Images behavior.

Preload Images Click the Add Behavior button (plus sign), and then click Preload Images.

A dialog box appears, allowing you to set the details of the action.

Preload Images Click Browse, locate and select the image you want to preload, and then click OK.

Preload Images

Preload Images Click the Add Items button (plus sign).

Preload Images To add more images, repeat steps 5 and 6.

Preload Images Click OK.

Preload Images To change the trigger, click the event, click the Event list arrow, and then select the event you want.

Swap Images

Swap Images Open the Web page you want to apply a behavior.

Swap Images

Swap Images Click the Window menu, and then click Behaviors to display the Behaviors panel.

Swap Images Click the image you want to swap.

Swap Images Click the Add Behavior button (plus sign), and then click Swap Image.

The selected image appears highlighted in the Swap Image dialog box.

Swap Images Click Browse, locate and select the image you want to swap it with, and then click OK.

Swap Images

Swap Images To insert a Preload Images behavior, select the Preload Images check box.

Swap Images To insert a Swap Image Restore behavior, select the Restore Images onMouseOut check box.

Swap Images To remove a swap, select an image in the list, and then delete the file and path in the Set Source To box.

Swap Images Click OK.

Swap Images To change the trigger, click the event, click the Event list arrow, and then select the event you want.

Changing Element Properties

The Change Property behavior allows you to change properties, such as font styles, borders or visibility, for an element on a Web page. The Change Property behavior is useful for adding interactivity to a Web page. For example, you can have the Change Property behavior display a text description or link address when a user points to a picture on a page. Along with the Change Property behavior, you can also use the Change Property Restore behavior, which restores the most recent property changes made by the Change Property behavior. When you use the Change Property Restore behavior, Dreamweaver displays a message dialog box acknowledging the use of the behavior. You can double-click the behavior to display a list of properties being restored.

Use the Change Property Behavior

Use the Change Property Behavior Open the Web page you want to apply a behavior.

Use the Change Property Behavior

Use the Change Property Behavior Click the Window menu, and then click Behaviors to display the Behaviors panel.

Use the Change Property Behavior Click the element you want to add the Change Property behavior (in this example, select the cell phone image).

Use the Change Property Behavior Click the Add Behavior button (plus sign), and then click Change Property.

A dialog box appears, allowing you to set the details of the action.

Use the Change Property Behavior Click the Type Of Element popup, and then select the type you want to change (in this example, select DIV).

Use the Change Property Behavior Click the Element ID popup, and then select an ID (in this example, select div “apTextSign”).

The AP element to the right of the cell phone image contains text, which you’ll change the font size to a larger size.

Use the Change Property Behavior Click the Select option and select the property you want to change (in this example, select fontSize), or click the Enter option and enter the property you want to change.

Use the Change Property Behavior

Use the Change Property Behavior Enter the new value you want (in this example, enter 24).

Use the Change Property Behavior Click OK.

Use the Change Property Behavior To change the trigger, click the event, click the Event list arrow, and then select the event you want.

Use the Change Property Behavior
Use the Change Property Behavior

Dragging an AP Element

The Drag AP Element behavior allows you let visitors on a Web page to drag an AP (Absolute Positioned) element. This behavior is useful for creating interactive training, games, and interface controls, such as a slider. The behavior allows you to specify how you want the AP element to move. You can constrain the movement in a specific direction, to a specific location or target, or to snap to another element. In order to use the Drag AP Element behavior, you need to call the behavior before the visitor can drag the element. To achieve this, you need to attach the Drag AP Element behavior to the body object with the onLoad event.

Use the Drag AP Element Behavior

Use the Drag AP Element Behavior Open the Web page you want to apply a behavior.

Use the Drag AP Element Behavior

Use the Drag AP Element Behavior Click the Window menu, and then click Behaviors to display the Behaviors panel.

Use the Drag AP Element Behavior Create the AP Element you want to add the Drag AP Element behavior.

Use the Drag AP Element Behavior Click <body> in the tag selector in the Document window.

Use the Drag AP Element Behavior Click the Add Behavior button (plus sign), and then click Drag AP Element.

A dialog box appears displaying the Basic tab.

Use the Drag AP Element Behavior Click the Movement popup, and then click Constrained or Unconstrained.

Use the Drag AP Element Behavior If you selected the Constrained option, enter values for Up, Down, Left, and Right (in pixels).

The values are relative to the starting position of the AP element. To constrain movement, use the following methods:

Rectangle. Enter positive values in all four boxes.

Vertical. Enter positive values for Up and Down and 0 for Left and Right.

Horizontal. Enter positive values for Left and Right and 0 for Up and Down.

Horizontal. Enter values for the Drop Target in the Up, Down, Left, and Right boxes (in pixels), or click Get Current Position to automatically insert the current position of the AP element.

The drop target is the spot where you want the visitor to drag the AP element. Values are relative to the top left corner of the browser window.

Horizontal.

Horizontal. Enter a Snap If Within value (in pixels) to specify how close the visitor needs to be to the drop target before the AP element snaps to the target.

Horizontal. To define the drag handle, track movement, and trigger an action, click the Advanced tab.

Drag Handle. Click the popup, and then select Entire Element or Area Within Element. For an area, enter values for the area you want within the element.

Drag Handle.

While Dragging. Select the Bring Element To Front, then check box, select a position, and then enter the script code or function you want executed during the drag.

When Dropped. Enter the script code or function you want executed when dropped, and then select the Only If Snapped check box to execute the code only if snapped.

When Dropped. Click OK.

When Dropped. To change the trigger, click the event, click the Event list arrow, and then select the event you want.

When Dropped.

Modifying a Navigation Bar

The Set Nav Bar Image behavior allows you to change an image into a navigation bar image or modify an existing navigation bar. You can change images depending on the current state of the navigation bar (either Up image, Over image, or Down image), or change the URL or select a window when a visitor clicks a navigation bar button. By default, clicking a navigation bar image causes all other images to display the Up state. You can specify advanced settings to change the default Up state to something else.

Use the Set Nav Bar Behavior

Use the Set Nav Bar Behavior Open the Web page with the navigation bar you want to change.

Use the Set Nav Bar Behavior

Use the Set Nav Bar Behavior Click the Window menu, and then click Behaviors to display the Behaviors panel.

Use the Set Nav Bar Behavior Select the image in the navigation bar you want to change.

Use the Set Nav Bar Behavior Click the Add Behavior button (plus sign), and then click Set Nav Bar Image.

A dialog box appears displaying the Basic tab.

Use the Set Nav Bar Behavior Change the options you want for the navigation bar image.

Use the Set Nav Bar Behavior

Use the Set Nav Bar Behavior Click OK.

See Also

See “Inserting a Navigation Bar” on page 174 for information on inserting a navigation bar and setting specific options in the Set Nav Bar Image dialog box.

Set Multiple Images for a Navigation Bar

Set Multiple Images for a Navigation Bar Open the Web page with the navigation bar you want to change.

Set Multiple Images for a Navigation Bar

Set Multiple Images for a Navigation Bar Click the Window menu, and then click Behaviors to display the Behaviors panel.

Set Multiple Images for a Navigation Bar Select the image in the navigation bar you want to set.

Set Multiple Images for a Navigation Bar In the Behaviors panel, double-click the Set Nav Bar Image action related with the event you want to change.

A dialog box appears displaying the Basic tab.

Set Multiple Images for a Navigation Bar Click the Advanced tab.

Set Multiple Images for a Navigation Bar

Set Multiple Images for a Navigation Bar Click the When Element Is Displaying popup, and then select one of the following options:

Over Image or Over While Down Image. Select to change the display of another image when the pointer is over the selected image.

Down Image. Select to change the display of another image after a visitor clicks the image.

Down Image. Select another image on the page.

Down Image. Enter the path and file name of the image or click Browse to select the image file.

Down Image. If you selected Over Image or Over While Down Image, enter the path and file name of the image or click Browse to select the image file.

Down Image. Click OK.

Showing and Hiding Elements

The Show-Hide Elements behavior allows you to show, hide, or restore the visibility of elements on a page. This behavior is useful for displaying information or providing interaction when a visitor points to an element. For example, when a visitor points to a picture or a text box, you can display information about the item to provide added value and some interactivity. When the visitor moves the pointer away, you can restore the element back to its original state.

Show or Hide Page Elements

Show or Hide Page Elements Open the Web page you want to apply a behavior.

Show or Hide Page Elements Click the Window menu, and then click Behaviors to display the Behaviors panel.

Show or Hide Page Elements Click the element you want to add a behavior.

Show or Hide Page Elements Click the Add Behavior button (plus sign), and then click Show-Hide Elements.

A dialog box appears, allowing you to set the details of the action.

Show or Hide Page Elements

Show or Hide Page Elements Click the element you want to show, hide, or restore.

Show or Hide Page Elements Click Show, Hide, or Default, which restores the default visibility of the element.

Show or Hide Page Elements

Show or Hide Page Elements Repeat steps 5 and 6 for each element you want.

Show or Hide Page Elements Click OK.

Show or Hide Page Elements To change the trigger, click the event, click the Event list arrow, and then select the event you want.

Executing a JavaScript

The Call JavaScript behavior runs a line of script when an event occurs. The behavior only runs one line of script, which means you can execute a single line of code or a procedure that calls a section of code. To use the Call JavaScript behavior, you need JavaScript experience and coding knowledge, which is outside the scope of this book.

Use the Call JavaScript Behavior

Use the Call JavaScript Behavior Open the Web page you want to apply a behavior.

Use the Call JavaScript Behavior

Use the Call JavaScript Behavior Click the Window menu, and then click Behaviors to display the Behaviors panel.

Use the Call JavaScript Behavior Click the element you want to add a behavior.

Use the Call JavaScript Behavior Click the Add Behavior button (plus sign), and then click Call JavaScript.

A dialog box appears, allowing you to set the details of the action.

Use the Call JavaScript Behavior Type the line of script you want to run.

Use the Call JavaScript Behavior

Use the Call JavaScript Behavior Click OK.

Use the Call JavaScript Behavior To change the trigger, click the event, click the Event list arrow, and then select the event you want.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset