[Previous] [Content Page] [Next]
Creating ActionsWhen you look at a group of complicated menus and dialog boxes, like the Behaviors task pane, you might have a hard time connecting the hodgepodge of choices to real world problems and solutions. Behaviors can add a lot of valuable and impressive features to your Web site, and actions are the fuel behind this magic. As you'll see, actions can help you route viewers to the pages you want them to see and shoot visitors specific messages based on choices they've made. You can also check to see if they have the software they'll need for a plug-in (a special program, like a video player) you've included in your Web page, or wow them with magically appearing images and menu selections. Again, when creating a behavior, you first select a tag on the page and then you pick the action. In the following pages, you'll learn what each action can do for you and how to configure it. After you set any one of these actions, it will appear in the Behaviors task pane, where you then set the event you want to trigger the action. 9.4.1. Actions to Control NavigationYou already know how to get visitors moving around your site using the trusty old hyperlink. As you'll see, a lot of actions in the Behaviors task pane let you take this kind of in-site navigation to a whole new level. 9.4.1.1 Creating a drop-down menuNumerous hyperlinks on the same screen can create clutter and confusion. But sometimes you don't have a choicesay you've got 26 cousins, and you've got to include links to all of them on your Favorite Relatives page. Text for all these hyperlinks can take up a lot of screen real estate. Why not consolidate? Instead of including a long list of hyperlinks on a page, you can create a drop-down list of links. This way the list, like the one shown in Figure 9-4, displays only if a viewer clicks on it.
FrontPage calls this feature a jump menu and provides a dialog box to help you make one. To create a jump menu:
Note: Links in a jump menu don't behave like regular hyperlinks. They won't show up in Hyperlinks view and they won't update automatically if you move a file into a different folder. So, if you want your menu to work, don't move any files (including the page that contains the menu) after you create this feature. 9.4.1.2 Jump Menu GoIf a visitor selects an item in a jump menu, she's immediately taken to the destination page. But what if you want to give her more time to think about it? You can pause things by adding a Go button next to your drop-down list. This way, when your visitor makes a selection from the list, she first has to press Go to open the page. If a visitor is a keyboard-only type person (as many visually disabled people are), she'll need a Go button to make a selection from the list. To add a Go button next to your jump menu, select Insert Now, the button will act as the hyperlink, connecting to whatever link a user chooses from the jump menu. But you've still got one more step: for the viewer to have a chance to click the Go button, you have to modify the jump menu itself to stop it from linking when a viewer clicks one of its choices. To do so, in the document window, select the jump menu. Its "onchange" behavior setting displays in the task pane. In the actions column, click on the jump menu to select it. Then, at the top of the task pane, click Delete. 9.4.1.3 Open Browser WindowSay you want a hyperlink's destination page to open in a new browser window, rather than replacing the current page. You already know how to do that after reading Tutorial 3. But maybe you don't want your viewers to contend with the usual menu and toolbar clutter of a new browser window. And say you also want to specify how big the window will be. No problem. The Open Browser Window action gives you all the control you want by letting you create and launch windows like the one shown in Figure 9-6. This action usually opens off a link, but you can base it on another event, like a page load, if you want. After all, all those pop-up ads that clutter your screen as you surf the Web aren't choices you've actively made. That's right. Now you'll know how to pester beleaguered readers with pop-ups, too. For the sake of Webkind, please use your power for good only.
Note: Keep in mind that many people configure their systems to block pop-ups (those based on a pageload event) and some browsers, like Mozilla's Firefox, block them automatically. After you've chosen your trigger element (a hyperlink or <body> tag), and selected Open Browser Window from the Behaviors task pane's Insert menu, the relevant dialog box opens. Then you can set the following options:
Tip: Taking away browser attributes isn't always cruel. Sometimes visitors lose track of what browser screens they have open. Say you've posted a special note or report that, for some reason, shouldn't appear on a regular pageone with links to the rest of your site. Taking away the navigation and menu bars is an easy way to communicate that a reader is at the end of the road. When he closes the new window, he's back where he belongs. 9.4.1.4 Go to URL (Redirect)Imagine that your company has been bought out, and your old name has been scrapped. What about people still trying to go to your company's old Web site, www.DowJones36000.com? It's a simple matter of redirecting them to your company's new site. Much like a hyperlink, the Go to URL behavior sends a browser to the URL you specify, but it provides more options. For instance, you can have the change happen when a viewer's cursor passes over something, or, more helpfully, when a page loads for the first time in a browser window. With DowJones36000.com, for example, you could create a barebones home page at this address and then redirect people to your new site (ShortSelling.com). To set up a redirect, select the <body> tag of the initial page you expect people to arrive at, and within the Behaviors task pane, select Insert Note: The onload event is triggered only after the entire page loads. So, if your page has a lot of images or content, viewers may get a glimpse of it before the action takes them to the new URL. This can look sloppy and disconcert your visitors, who may worry that the browser's been hijacked. If you want a lightning-fast, imperceptible transition, then put very little on the dormant page. However, you should include some text and link to your new site, just to be thorough. If setting the action on the onload event creates a switch that's too fast for you, or you want to be sure your visitors know your site has moved, you could base the Go to URL behavior on another event, like a click on a link or picture. You can also set your own schedule. See the box "Redirect on a Time Delay."
9.4.1.5 Check BrowserThroughout this book, you've been hearing over and over about browser supportor lack thereoffor certain features. If you've already tested pages in a variety of browsers, you've probably seen how differently they can display the same page. Web designers sometimes get around this problem by creating more than one version of all or parts of their site. These alternate pages are identical but designed specifically for different browsers. In other words, one company may have two separate, but identical Web sites: one for Internet Explorer and one for Netscape. Designers then implement the Check Browser Behavior to direct a visitor to the appropriate site. (After which they go drink buckets of soothing herbal tea, in order to calm nerves jangled by the existence of so many different browsers.) Did you ever wonder why some sites on the Web have a home page that contains only one link that says something like "Click to Enter"? A hyperlink like this can serve as the trigger event for the check browser action. Say you've loaded a page with the IE-only DHTML effects covered earlier in this tutorial. You can do other browser owners a favor and use such a trick to steer them to an alternate page. Tip: While you might be tempted to have a page load event trigger this action, don't forget that the onload event starts only after the entire page has loaded. If you're trying to steer viewers away from the page in question, it'll be too late. To implement this behavior, select the tag (usually a link) that will trigger your event. Then, within the Behaviors task pane, select Insert Unfortunately, you can set only one browser apart from the pack here. Also, your choices are limited to those that Microsoft has providedyou can't add a browser here as you can when you're previewing pages. In the "If current browser type is" drop-down menu, select a browser and version you'd like to set as the target. Then turn on the Go to URL checkbox beneath that field and browse to the correct page. To set another page for all other browser types, turn on the Go to URL checkbox on the bottom and, in the corresponding field, browse to the alternative page. Then click OK and set your event as you would for any behavior.
9.4.2. Actions to Control MultimediaIf your site includes Flash or video files, you may want do to more than just throw them up on a page and hope your viewers can see them. FrontPage offers a few actions to help make sure your bells and whistles are actually jingling, blowing, and moving properly. 9.4.2.1 Check Plug-inIf you can't tell what browser a viewer might have, how would you know what other software he has loaded on his machine? Just as you might want to create different pages to accommodate different Web browsers (Section 9.4.1.5), you might also want to separate versions of pages for visitors who've got different kinds of plug-ins. (Plug-ins are miniature programs that play audio, video, and other specialized files directly within a browser's window.) For example, you might create two copies of the same page, one featuring a video in QuickTime, while the other shows it using RealPlayer. Use the Check Plug-in action to direct your viewers to the appropriate page. This action works a lot like the Check Browser action. First, select a trigger tagfor instance, a link to a video. Then, in the Behaviors task pane, select Insert 9.4.2.2 Play an Audio FileMaybe you want an event to play a sound? You're in luck. The play sound action supports WAV, MIDI, Real Audio, AIFF, and AU sound files. Unfortunately, this behavior works only in Internet Explorer. Select the page element that'll trigger the sound and, within the Behaviors task pane, click Insert Tip: You may want to add a sound that plays in the background while visitors have your page open in their browser. You don't need an action to do this. There's a setting in Page Properties that lets you have the sound loop continuously while the page is open. Think twice, however, before creating this racket. Your visitors may find such noise intrusive and annoying, since they have no control over it (other than hitting their computer's mute button or, worse, leaving your site).Also, depending on the size of the audio file, adding sound could really slow down your page, and it won't work in Netscape Navigator. But sound might be appropriate in certain situations. To add it, first select File 9.4.2.3 Control Properties in FlashWhen you learned to insert Flash movies in Tutorial 4 (Section 4.4.2), you saw that FrontPage gives you basic control over Flash properties like height and width. The Control Properties in Flash action lets you control more obscure Flash properties. For instance, you could have the display window zoom in on the movie or pan across it. To implement this action, select the trigger tag. This could be a button that says Rewind or Stop, depending upon what controls you want to give your viewers. Then within the Behaviors Task pane, select Insert
To learn more about the selections above and the others in this dialog box, visit www.macromedia.com and type "Flash methods" in the site's search box. Note: The Control Properties in Flash action works only in Internet Explorer 6.0. Some methods, like zoom, may work in earlier versions of IE, so you can give them a try, but your audience for this action is pretty much limited to those who've got Microsoft's latest browser. 9.4.3. Actions to Send MessagesYou may find yourself occasionally wishing you had additional ways of reaching out, across the Web, and sending small notes to your site's visitors or quickly changing the information they're looking at. The following methods may be just what you're looking for. 9.4.3.1 Pop-up MessageIf you need to alert your visitors to an important issue, use this action to make a pop-up message box appear in front of a viewer, based on a click or other trigger. These pop-ups aren't pretty windows like the ones you can make with the Go to URL action (see Figure 9-6). Instead, these look like regular Windows error message boxes that contain whatever text you specify. (Consider this your chance to write something slightly more friendly than the typical Microsoft missive.) Select the element that'll act as a trigger, then within the Behaviors task pane, click Insert 9.4.3.2 Set Text of FrameYou can use this action to replace the content of a frame (pop back to Tutorial 6 for a refresher on all things frame related). The term "set text" doesn't really convey the power of this action. The fact is you can include images, tables, or whatever you want. You're essentially replacing the HTML in the frame with new HTML. It's like loading a new page in the frame, but because the HTML is already part of the page, it's lightning fast. To apply this action, you'll need to have a frameset in place. Select the trigger tag or object and then, within the Behaviors task pane, select Insert
9.4.3.3 Set Text of LayerThe Set Text of Layer action works like the Set Text of Frame action, butas you might guessreplaces the content of a layer with whatever HTML you want. To implement this action, first select a tag. Then, within the Behaviors task pane, select Insert
9.4.3.4 Set Text of Status BarUse this action to have a message appear in the status bar. Where's the status bar? It's the strip at the bottom of your browser (see Figure 9-7). For instance, you can use this action to have a description or credit for an image appear when a visitor passes her cursor over it. To create this action, first select the trigger tag (like <img> for an image). Then, within the Behaviors task pane, select Insert 9.4.3.5 Set Text of Text FieldYou'll read all about forms when you get to Tutorial 15, but you've probably filled out hundreds of them yourself. You visit a page, fill in a few blanks, and then click Submit. Next thing you know, the fishing lures you ordered are en route to your cabin in the woodsall based on the information you entered in the form. When it comes time to create your own forms, you can use the Set Text of Text Field action to help visitors out by adding text to certain fields in response to viewer actions. For instance, say you ask a visitor "Do you have an alternate address?" and provide radio buttons for Yes and No. If a viewer clicks on the No radio button, you can trigger the Set Text of Text Field action to fill the alternate address field with a note that says "Please proceed to the next question." To do so, first select the radio button that'll act as the trigger. Then, within the Behaviors task pane, select Insert
9.4.4. Image ActionsIf you think graphics can spice up a Web page, just wait until you add a few actions to your pictures. 9.4.4.1 Swap ImageYou've already read about a couple of ways to swap images. For example, FrontPage's interactive buttons automatically add image-swapping behavior to a page to generate a rollover effect. Then there's the DHTML Effects toolbar, which also provides a handy shortcut. But neither of these methods quite measure up to the Swap Image action in the Behaviors task pane, which gives you loads more fine-tuning options. For example, say you have a page all about your trip to Alaska that opens with an impressive landscape photo you took. You can place a list of towns you visited down the left side of your page. When a viewer clicks on Skagway, a picture of that town replaces the landscape photo. Using the Swap Image behavior, you've made your own Alaska slideshow. Tip: To achieve a similar effect, you could insert your pictures in layers (see Tutorial 8) and use the Change Property behavior to control layer visibility settings (see "Advanced Action: Change Property" on Section 9.4.5). To create an image swap action follow these steps:
Note: If you do set the event to be a click on a paragraph, be aware thatas with collapsible menusyour viewer may have trouble knowing that he needs to click in that spot, because his cursor won't change into a "click here" pointing hand like it does when he hovers over hyperlinks (see Figure 2-12, back on Section 2.5.2.1). For this reason, you may want to use the onmouseover event instead. 9.4.4.2 Preload ImagesAs anyone with a slower Internet connection knows, images can take a long time to download. The Preload Images action downloads image(s) onto a viewer's machine before they display on a page. Why would you want to do this? Say you've added a rollover button or other image swap to your page. When a viewer's cursor passes over it, the second image is supposed to replace the first. If your visitor had to wait for that second image to download, this effect would be ruined (it'd be kind of like a magician saying "ta-dah!" and then making her audience wait for the payoff spectacle). By the time the image appears, the cursor might be off on another part of the page, creating confusion. In fact, when you insert FrontPage's interactive buttons (Section 9.2.2), the program automatically adds this action to ensure that the buttons work properly. You want to attach this action to the body tag's onload event. Once you've selected the tag, open the Behaviors task pane and select Insert
When the list is complete, click OK, and then set the event to onload (if FrontPage hasn't already done so). 9.4.5. Advanced Action: Change PropertyNow that you're familiar with all these different actions, you're ready for one that's slightly more intricate and bursting with possibilities. The Change Property action lets you modify the appearance and/or placement of an object. This behavior changes font style, visibility, borders, or position. You can do something simple, like have a layer background change color on a cursor pass, or you can use this action to create complicated screen choreographya click on one button makes multiple pictures move around the screen. The basic steps for changing properties of an element are the same as setting any other behavior, but you'll have to go through a bit more work when adjusting the settings in the dialog box. The following steps take you through the basic guidelines for completing the dialog box. To see this "action" in action, follow the tutorial at the end of this tutorial, which shows you how to use Change Property to animate a cascading menu system consisting of layers. After you've selected the element that you want to trigger the Change Property action and accessed the Behavior pane's Insert Now follow these steps:
Within the Behaviors task pane, the event is often automatically set to onclick. Click it and select another, if you wish.
|
[Previous] [Content Page] [Next]






