See the sidebars
“Open with Animation”
“What Browser Is That?”
“Make Easy Rollover Buttons”
Another catch is that you can view DHTML effects correctly only using version 4.0 or later browsers. Even then, some effects are Internet Explorer-specific and some are Navigator-specific. It’s essential to preview your pages in both browsers, preferably in both the Mac OS and Windows.
Whole books explain how to code DHTML, but we’ll leave the programming to people who enjoy that sort of thing. For the rest of us, there’s GoLive CyberStudio Professional Edition 3 and later ($299; 650/463-1580,
To illustrate some DHTML elements, we created a few pages of a mythical sporting-goods site called Adventure Tools (you can see this site in action
). The opening page of the site is an animated splash screen with three elements that fly across the page and assemble to form the Adventure Tools logo (see “Open with Animation”). A few seconds after the animation ends, the splash screen automatically jumps to the site’s home page (shown above).
With DHTML-savvy tools such as CyberStudio Professional Edition, designers get to concentrate more on designing and less on programming, and don’t have to rely on Web programmers. You can create sites faster and more easilyand in the world of Internet Time, this is an important consideration.
WHAT YOU NEED
GoLive CyberStudio Professional Edition 3
- Web browser
- Web graphics editor (optional)
TOM NEGRINO is coauthor of
, second edition (Peachpit Press, 1998).
Open with Animation
The splash screen is your site’s snazzy “foyer,” which ushers Web surfers to the main page. This is a great place to employ animation. There are three moving elements on our splash screen: a globe, a skier, and the
title. Each element is a transparent GIF image embedded in a floating box. The animation consists of the GIFs flying in along different paths, finally assembling the complete logo (see this in action
). It’s important that the images be transparent GIFs, so you can see one image behind another when they’re stacked.
Begin by dragging the Floating Box icon
from the Basic tab of the CyberStudio Palette onto an empty page you’ve named Splash.html. You do this once for each image in your animation (in this case, three images). Into each floating box, drag an Image placeholder
from the Basic tab of the Palette. In the Image Inspector, specify the image file with the Browse button
or use the Point & Shoot button
to find the image in the Site window. Resize the floating boxes so they fit snugly around their images, and then position the boxes where you want the images to be at the end of the animation.
To animate the first floating box, click on the edge of the box to select it. Then open the Timeline Editor
by clicking on the Timeline Editor button in the upper right corner of the document window. In the Timeline Editor window, there are three tracks and three keyframes, one for each of the floating boxes. These keyframes represent where the images will end up, so you need to reposition them along the timeline.
Decide how long you want the animation to last, and drag the three keyframes to that spot on the timeline. After you move the keyframes, you’ll notice that each track leaves behind a dimmed keyframe at the beginning of the timeline (indicating that the track is not visible at that point on the timeline). Click on the dimmed keyframe on track 1 to select it. Click on the Visible check box in the Floating Box Inspector, and then drag the floating box in the document window to where you want it at the beginning of the animation. Click on the play button
at the bottom of the Timeline Editor to preview your animation. You can adjust the speed of the animation by changing the frames per second via the FPS pop-up menu
at the bottom of the Timeline Editor.
If you want, you can add keyframes in the middle of the animation by command-clicking on a track on the timeline. This allows you to create a complex path the image will follow. You can smooth the path by choosing Curve under Animation Type in the Floating Box Inspector.
Repeat the above processes to animate the other two floating boxes.
Now, to make the splash screen switch automatically to the home page, you’ll use an HTML tag that goes in the header of the page. It’s a short bit of code, so if you like you can switch to CyberStudio’s Source mode and type
tags. If you prefer Layout mode, click on the disclosure triangle
at the top of the splash page to open up the Head Section of the page. Under the Head tab
in the Palette, drag the Refresh icon to the Head Section. In the Refresh Inspector that appears, enter a delay time in seconds (5 is a good number), click on the URL button, and enter the name of the page to which you want to jump.
What Browser Is That?
Fancy DHTML animation looks great to people who have version 4.0 or later browsers, but people with earlier versions (and that includes most people who use America Online) won’t see the animation. For these folks, the Adventure Tools splash page will just look like a blank colored page. You can’t control what browsers people use, but you can make your page handle older browsers gracefully by having it perform
, which sniffs out the browser version that’s loading the page. If the browser is capable of handling DHTML, the page loads normally. But if it isn’t, the browser switches to a simpler page you’ve prepared without DHTML. You can use browser detection on the entry page of your site to redirect users with older browsers to a completely different, simpler version of your site.
To add browser detection to the splash page, drag the Browser Switch Item from the CyberObjects tab in the Palette to the header of the splash page (click on the disclosure triangle to open up the Head Section).
Cascading Style Sheets help solve a pet peeve of Web designers: lack of fine control over the style and appearance of text. The detailed ins and outs of Cascading Style Sheets are beyond this article’s scope, but we can show you how to create Tag Styles, which let you apply style rules to any HTML tag within a document. For example, you can apply instant styling to all of the
tags throughout your document so that when you change the style definition, all text in your document tagged as H2 also changes.
Select some text on your page and choose Header 2 from the tool bar’s Paragraph Format pop-up menu . To create a text style sheet, click on the Style Sheet button at the top of the document window. A new style-sheet window opens and the style tool bar appears on top. Click the New Tag button on the tool bar.
In the CSS Selector Inspector, type
in the Name field. Type in the name of a valid HTML tag, but omit the usual angle brackets (< and >). Set the font, style, background, alignment, and other attributes for the new H2 style using the rest of the tabs in the CSS Selector Inspector. Note that as you change the attributes, the text you designated as H2 also changes. When you’re done, the formatting you selected appears under the Basics tab.
Make Easy Rollover Buttons
One of the most useful and common DHTML effects is the button rollover. This simple animation makes a button change appearance when the user moves the mouse cursor over the button or clicks on it. What actually happens is that the browser swaps one version of the button image for another. The Adventure Tools site uses rollovers in the navigation bar on the main page. Here’s how.
First, make a button. Adobe’s ImageStyler and Macromedia’s Fireworks make creating rollover buttons a snap, much easier than with Adobe Photoshop. But no matter what you use, make sure the different images for the button’s various states (rollover, click on, and so forth) are exactly the same size and resolution. Otherwise, the browser will scale the second image to fit into the same space the first image took up, and the transition between the images will look awkward.
Also make sure your buttons are opaque GIFs or JPEGs, not transparent GIFs. If the image is transparent, the user will see one button on top of another, instead of one button replacing another.
Now open the page that will contain the button. In the CyberStudio Palette, click on the CyberObjects tab , and then drag the Button Image icon to the document window.
Name the button in the Button Inspector, and then click on the square marked Main. This is the image you’ll see when the cursor is not hovering over the button. Use the Browse button or Point & Shoot button to select the image.
Click on the box in the Button Inspector marked Over. Click on the check box next to the Image Path field, and then use Browse or Point & Shoot to select the image you’ll see when the cursor is over the button. If you like, you can repeat the process a third time with the Click box, which replaces the button image with a third image when the user clicks on the button.
Buttons are usually linked to other pages. Click on the Status & Link tab, click on the URL check box, and then use Browse or Point & Shoot to create the link to the new page. Because the navigation bar on this page is part of a frame set, you’ll need to set the target of the link. Choose Body from the pop-up menu next to Target.
If you want a text message to show up in the status bar of the browser when the user rolls the cursor over a button, click on the Status check box and enter your message.