JavaScript for the World Wide Web: Visual QuickStart Guide, Third Edition is the book for people who already know how to build Web pages with HTML, and are ready to take the next step in making their sites more interesting and exciting. With an easy, step-by-step approach and loads of useful illustrations, readers learn to use JavaScript to liven up their pages with dynamic images and smart forms. They'll learn to control browsers; detect which browser or plug-ins the user has and automatically take action; use JavaScript to create and manipulate windows, and much more.
"synopsis" may belong to another edition of this title.
Tom Negrino is a best-selling book author and contributing editor to Macworld magazine. He is the co-author of two previous editions of this book.
Dori Smith writes the JavaScript columns for Macworld and DevX, and is a contributing editor for MacTech. She is the co-author of the previous editions of this book, and author of Java for the World Wide Web: Visual QuickStart Guide.
Does the following sound familiar? You know how to build a good-looking Web page, but you'd like to add some excitement and interactivity to your site. Then the next step is JavaScript, a programming language designed to make HTML more powerful and dynamic. You don't need to be a seasoned programmer to master JavaScript--just a copy of JavaScript for the World Wide Web: Visual QuickStart Guide. This third edition of the best-selling guide includes expanded coverage of such essential topics as how to liven up your pages with dynamic images, add smart forms, and detect which browsers and plug-ins your visitors are using so you can customize the content they see. What hasn't changed is the book's clear, step-by-step approach and generous sample code and screenshots. With JavaScript: VQS, you get both an excellent introduction to the language and a handy reference tool.
These are updates of titles that continue to sell; all are very visual and practical.
Copyright 1999 Reed Business Information, Inc.
One of the best uses of JavaScript is to add excitement to Web pages by animating graphics, and that's what this chapter is all about. Making images on Web pages change when the user moves the mouse over the image, thereby making the page react to
the user, is one of the most common-and effective-tricks you can learn in JavaScript. This rollover, as it is called, is easy to implement, yet has many applications, as you'll see.
You can also use JavaScript to create images that change automatically, and even make animated advertising banners that take the place of animated GIF files.
Creating More Effective Rollovers
To make the illusion of animation work, you need to make sure that the replacement image appears immediately, with no delay while it is fetched from the server. To do that, you use JavaScript to preload all the images into the browser's cache (so that they are already on the user's hard disk when they are needed) and place the images into script variables. Then when the user moves the mouse over an image, the script swaps out one variable containing an image for a second variable containing the replacement image. Script 3.2 shows how it is done. The visible result is the same as in Figures 3.1 and 3.2, but the apparent animation is smoother.
To create a better rollover:
1. if (document.images) { arrowRed = new Image arrowBlue = new Image arrowRed.src = 'images/redArrow.gif arrowBlue.src = 'images/blueArrow.gif }
This code checks to see if the browser understands image objects (see sidebar). If the browser does, the code assigns arrowRed and arrowBlue to two separate image objects. Then, using the .src property, it fills the two objects with the GIFs of the red and blue arrows.
2. else { arrowRed = arrowBlue = document.arrow = }This is the code that tells old browsers (ones that failed the test in step 1) what to do. In order to keep from getting error messages in old browsers, we have tocreate some dummy variables-that is, variables that won't do anything but be created and set to empty. Think of them as placeholders. Create two variables named arrowRed and arrowBlue, andset them to empty. Then create and set document.arrow to empty, too.
3. The rest of the rollover gets handled in the link tag. When the user puts the mouse over the blue arrow graphic (onMouseover), the script swaps the blue arrow for the graphic with the red arrow (document.arrow.src=arrowRed.src). When the mouse cursor leaves the area of the graphic, the script reverts the graphic back to the blue arrow.
Tips
When you prepare your graphics for rollovers, make sure that all your GIF images are not transparent. Transparent images will show the image they are replacing underneath.
Both the original and the replacement images need to have identical dimensions. Otherwise, the browser will resize the images for you and probably won't like the distorted result.
Triggering Rollovers
from a Link
In prior examples, the user triggered the rollover by moving the mouse over an image. But you can also make a rollover occur when the user points at a text link, as in Figures 3.3 and 3.4. All you need to do is to puta text link within the
Note that the text link that says Next page is within the link tag, which makes it the thing that onMouseover and onMouseout use as a trigger. We've moved the IMG tag out of the link tag; it nowfollows the link tag.
"About this title" may belong to another edition of this title.
FREE shipping within U.S.A.
Destination, rates & speedsSeller: SecondSale, Montgomery, IL, U.S.A.
Condition: Good. Item in good condition. Textbooks may not include supplemental items i.e. CDs, access codes etc. Seller Inventory # 00070356651
Quantity: 2 available
Seller: Better World Books, Mishawaka, IN, U.S.A.
Condition: Good. Used book that is in clean, average condition without any missing pages. Seller Inventory # 2238802-6
Quantity: 1 available
Seller: Better World Books, Mishawaka, IN, U.S.A.
Condition: Very Good. Used book that is in excellent condition. May show signs of wear or have minor defects. Seller Inventory # 38467569-6
Quantity: 1 available
Seller: Once Upon A Time Books, Siloam Springs, AR, U.S.A.
paperback. Condition: Good. This is a used book in good condition and may show some signs of use or wear . This is a used book in good condition and may show some signs of use or wear . Seller Inventory # mon0000861712
Quantity: 1 available
Seller: Wonder Book, Frederick, MD, U.S.A.
Condition: Very Good. Very Good condition. 3rd edition. A copy that may have a few cosmetic defects. May also contain light spine creasing or a few markings such as an owner's name, short gifter's inscription or light stamp. Seller Inventory # T05P-01834
Quantity: 1 available
Seller: Wonder Book, Frederick, MD, U.S.A.
Condition: As New. Like New condition. 3rd edition. A near perfect copy that may have very minor cosmetic defects. Seller Inventory # J09C-01233
Quantity: 1 available
Seller: ThriftBooks-Dallas, Dallas, TX, U.S.A.
Paperback. Condition: Good. No Jacket. Pages can have notes/highlighting. Spine may show signs of wear. ~ ThriftBooks: Read More, Spend Less 1.1. Seller Inventory # G0201354632I3N00
Quantity: 1 available
Seller: WorldofBooks, Goring-By-Sea, WS, United Kingdom
Paperback. Condition: Very Good. The book has been read, but is in excellent condition. Pages are intact and not marred by notes or highlighting. The spine remains undamaged. Seller Inventory # GOR003621561
Quantity: 1 available
Seller: Top Notch Books, Tolar, TX, U.S.A.
Soft Cover. Condition: Good. Wraps have light wear. Pages are clean & text is free from markings. All pages secure in binding. Size: 8vo - 7¾" - 9¾" Tall. Seller Inventory # 011271A
Quantity: 1 available
Seller: gigabooks, Spokane, WA, U.S.A.
Trade Paperback. Condition: Very Good. Trade Paperback - VG - Book is clean and tight with light wear - Index - 292 pages. Seller Inventory # 254488
Quantity: 1 available