Working with Special Effects
Monday, January 19th, 2009This week’s material is fun to work with!
This tutorial explains how to create rollovers, menus, filters and transitions. Students learn how to create and use different types of effects in their Web pages, and how to use some of these effects as Web page navigation aids.
Make sure you look back to Tutorial 11 and review object collections if you’ve forgotten what those are. They are explored further this week. The Reference Window on page 638 describes how to reference an inline image. Be aware that an image can be referenced by its name, but since the name attribute has been deprecated in favor of the id attribute, it’s generally safer to use the document.images object collection. For backward compatibility with older browsers, it is recommended to use both the id and name attributes, set to the same value. Don’t forget the importance of good cross-browser Web site design as there are still many people using older versions of browsers. Also remember that there are a good number of browsers available and that your users (customers) will probably use most of them.
You can write code that detects if a browser supports image objects. If a browser does not support image objects, the rollover effect cannot be obtained, but with good Web development practices, the users should be able to navigate through the Web site without problems. If users have problems navigating your site they won’t stay and you will probably lose a customer.
There are two types of menus: pop-up and pull-downs. You should be familiar with both of these. A pop-up menu can be created using hidden <div> elements and JavaScript code. The clip style attribute can be used to create pull-down menus. Make sure you do the example that is in the book so you know how to do this. Create pop-up menus using JavaScript code. A pop-up menu should appear when the user clicks (or onmouseover, depending on the design) on a menu title. Only one pop-up menu should be visible at a time. If a user clicks the page content that appears below the menus, any active menu should be hidden. JavaScript to show and hide a menu needs to be created.
A function to display the appropriate pop-up menu and to hide all others should also be created. This function will be called when the user clicks on a menu title, specifying it in the href property of the <a> tag. The section exercise explains in detail how to create a pop-up menu for the case study (hint, hint).
A filter is an effect that is applied to an object or page to change its appearance. Using Internet Explorer filters, you can make text or images appear partially transparent, add a drop shadow, or make an object appear to glow. Filters were introduced in Internet Explorer version 4.0 and are not supported by other browsers, so they should be used with caution (I don’t recommend using them at all unless you always get the browser type the user has installed). You should run the filter demo (see page 659) so that you know what these are and how to use them.
A transition is a visual effect that is applied to an object over an interval of time. Transitions are only supported by the Internet Explorer browser. Internet Explorer 4.0 supports two types of transitions: blend and reveal. The Reference Window on page 668 shows how to create transition styles. The section also includes a transition demo. Make sure you check this out. On pages 672-673, a step-by-step exercise shows how to add a transition to a pop-up menu.
Interpage transitions, involve effects applied to a page when a browser either enters or exits the page. Interpage transitions are created using the meta element within the head section of the HTML file. There are four types of transitions, which are run when a user initially enters the Web page, exits the page, enters the Web site, or exits the site, respectively. The Reference Window on page 674 describes how to create an interpage transition.
Finally, the section contains a step-by-step exercise showing how to add an interpage transition to a Web page.