Script Examples for
JavaScript for the World Wide Web:
Visual QuickStart Guide, 3rd Edition


This page gives you access to all of the scripts in our book, listed by chapter and task names. We've given you two ways to use the scripts; if you want to see what a script does, click the "Run Script" link next to the name of the task, and a new window will open and run that script. If you want to view the code, or copy it for your own use, click the "View Source" link next to the task.

Or, you can download all the scripts and images as a single zipped file here.

We've also included the images associated with all of the examples in the book; the images for each task are always below the script for that task when you click one of the "View Source" links. Please be aware that you may use the images from this Web site only for the purpose of learning or teaching JavaScript; you may NOT use these images on other Web sites without our express written permission.




Chapter 1: Getting Acquainted with JavaScript

   What JavaScript is Run Script View Source


Chapter 2: Start Me Up!

  Where to put your scripts
Hiding scripts from old browsers
Putting comments in scripts
Alerting the user
Redirecting the user
Redirecting the user with a link
Browser detection and conditionals
Plug-in detection
Around and around with loops
Functions
Putting more than one script on a page
Scrolling status bars
Status bar messages
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source


Chapter 3: Fun with Images

  Creating rollovers
Creating more effective rollovers
Triggering rollovers from a link
Multiple images changing a single rollover
Working with multiple rollovers
Using a function to simplify coding multiple images
with a single rollover
Using a function to simplify coding multiple rollovers
Creating cycling banners
Making the banner cycling wait for the user
Adding links to cycling banners
Building slide shows
Building wraparound slide shows
Displaying a random image
Combining a rollover with an image map
Automatically changing background colors
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script

Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
View Source
View Source
View Source
View Source
View Source
View Source

View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source


Chapter 4: Frames, Frames, and More Frames

  Keeping a page out of a frame
Forcing a page into a frame
Forcing a site into a frame

Loading a frame
Creating and loading a dynamic frame
Sharing functions between frames
Storing information in frames
Loading multiple frames at once
Browser detection with frames
Run Script
Run Script
Run Script and
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
View Source
View Source
View Source

View Source
View Source
View Source
View Source
View Source
View Source


Chapter 5: Working with Browser Windows

  Opening a new window
Loading different contents into a window
Opening a new window using an image link
Scrolling a window
Updating one window from another
Creating new pages with JavaScript
Closing a window
Creating a control panel
Positioning a window on the screen
Displaying an alert when a window is loaded
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source


Chapter 6: Verifying Forms

  Verifying passwords
Select-and-go navigation
Complete script
Run Script
Run Script
Run Script
View Source
View Source
View Source


Chapter 7: Making Your Pages Dynamic

  Putting the current date into a Web page
Working with days
Customizing your message for the time of day
Converting military time to AM/PM
Creating a countdown
Working with referrer pages
Writing text on the fly
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
View Source
View Source
View Source
View Source
View Source
View Source
View Source


Chapter 8: JavaScript and Cookies

  Baking your first cookie
Reading a cookie
Showing your cookies
Using cookies as counters
Deleting cookies
Handling multiple cookies
Displaying "New to You" messages
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
View Source
View Source
View Source
View Source
View Source
View Source
View Source


Chapter 9: Java and Plug-ins

  Checking if Java is enabled
Getting the user's monitor size
Using Java to display text
Playing sounds using a plug-in
Playing a sound on a rollover
Run Script
Run Script
Run Script
Run Script
Run Script
View Source
View Source
View Source
View Source
View Source


Chapter 10: Working with CSS and External Files

  Moving an object in two dimensions (Netscape)
Moving an object in two dimensions (IE)
Moving an object in two dimensions (all)
Moving an object in three dimensions (Netscape)
Moving an object in three dimensions(IE)
Moving an object in three dimensions (all)
Moving DHTML text (Netscape)
Moving DHTML text (all)
Modifying a DHTML drop shadow (IE)
Rotating a DHTML shadow (IE)
Modifying a DHTML glow (IE)
Pull down menus (all)
Sliding menus (IE)
Tool tips (all)
Using an external .js file (all)
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
Run Script
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source
View Source