Adding JavaScript effects
In the beginning, the kinds of things Web authors could do inside a Web page were quite limited. There was content—the words and images that make up a document; and there was markup—the HTML tags that tell Web browsers how to present the content. As the Web grew and Web authors started wanting to do more with their pages, it became obvious that something was missing: a way to make Web pages dynamic.
A dynamic Web page is one that can change in some way after it is opened in a browser. For example, a dynamic page might have a menu in which clicking an item reveals a submenu of links that were previously hidden. There is no way to create such a menu with pure HTML, since HTML provides no way for authors to instruct browsers to change something in a document in response to user actions (such as clicking a menu item). What is needed is the ability to program the browser—to tell it something like, “If event X takes place, then do Y.” JavaScript provides this capability.
JavaScript is a scripting language designed for the Web. A script is a program that is stored as plain text and is “run” by a host program, such as a Web browser. Scripts written in JavaScript can be included directly within Web documents. When a browser that supports JavaScript opens a document containing a script, it loads the script into memory and executes it either right away or later, in response to some event. Although other Web-oriented scripting languages exist (most notably VB Script), JavaScript is the most widely supported by browsers and operating systems.
These are just a few of the kinds of dynamic effects that JavaScript makes possible in Web pages:
- Replacing an image with another image when the user moves the pointer over it
- Revealing or hiding a block of content when the user clicks a button
- Displaying a message (dialog) box when the user clicks a hyperlink
- Moving an image along a predefined path
- Causing an image or text to follow the pointer as the user moves the mouse
Fortunately, you don’t have to know how to program in JavaScript to be able to add useful scripts to your documents. Namo WebEditor provides three ways to add scripted effects without writing scripts.
The Script Wizard
The Script Wizard provides an easy, step-by-step interface for adding twenty of the most popular JavaScript effects to your page, from image rollovers to expanding menus.
Actions and events
Through the Actions window, you can “attach” any of eighty built-in scripts (“actions”) to various kinds of page elements and specify the event that triggers the action. The built-in actions include applying an alpha effect, flipping a layer, inserting text, and many more.
Timelines
A timeline is a predefined sequence of movements and other changes (such as becoming hidden or visible) that apply to one or more layers over a period of time. In other words, a timeline is a way to animate page content. Timelines are created in the Timeline window.
In this section
Working with actions and events