JavaScript is a truly powerful tool. If you're a diehard alpha nerd who likes to program your TiVo to talk to your BlackBerry, you'll enjoy long nights of JavaScript coding. However, if you don't like to lie awake wondering what var howMany = (trueTop>1?"s" : ""); really means, you'll probably be happier if you let someone else do the heavy lifting .
If you fall into the non-programmer camp, this chapter has some very good news. The Web is flooded with free JavaScript. In fact, it's easier to find free scripts than clip art, style sheets, or MIDI music. Most of the time, these scripts include step-by-step instructions that explain where to put the functions, what tags to use in your page, and how to hook your tags up to functions using events.
Although the list of JavaScript sites is too long to print, here are some good starting points:
http://webdeveloper.earthweb.com/webjs
Offers a huge collection of JavaScript standards.
http://javascript.internet.com
Provides a solid catalog of 2,000 bread-and-butter scripts.
www.javascript-2.com
Tips the scales with a staggering 9,000 scripts.
www.dynamicdrive.com
Provides a smaller set of scripts that emphasize modern DHTML-based programming techniques. Includes exotic scripts like glowing green letters that tumble down the page, Matrix-style. Offers many scripts that are IE-only, but clearly indicates browser support for each script.
www.javascripter.net/faq
Unlike the other sites, this one doesn't offer a catalog of complete downloadable scripts. Instead, it's organized as a set of frequently asked JavaScript questions, with the relevant code for each answer.
http://webmonkey.wired.com/webmonkey/programming/javascript
Unlike the other sites, this one offers a smaller set of detailed JavaScript tutorials instead of a huge variety of standalone scripts. Useful if you want to learn more about some of the core JavaScript techniques.
Using this list, you can dig up everything from little frills to complete, functioning Tetris clones . But keep in mind that a script is only as good as the coder who created it. Even on sites with good quality control, you could stumble across a script that doesn't work on all browsers or slows your page down to a sluggish crawl. As a rule of thumb, always try out each script thoroughly before you start using it on your site.
Ready to hunt for scripts online? The next series of steps takes you through the process from beginning to end.
Fire up your browser and choose your site .
In this example, you'll use www.dynamicdrive.com.
Choose the category that you want from the site's home page (Figure 14-11) .
In this case, you'll use the Documents Effects category. For a sample of what else you can find, see the box "Script Categories."
|
Scroll through the list of scripts in your category (Figure 14-12), and click one .
In this case, you'll use the Top-Down Stripy Curtain Script.
The next page shows an example of the script (Figure 14-13) .
Once the next page loads, you'll find a script description, the author's name , and a link to try the script out (if it wasn't already used on the page). Underneath all this information are the step-by-step instructions you need to use the script.
|
|
Follow the instructions to copy and paste the different parts of the script into your page (Figure 14-14) .
Often, you'll get a set of functions (which you need to place in the <head> portion of your page) and then some HTML tags (which you need to place in the <body> section). In some cases, you'll be able to customize your scriptsfor example, you might modify numbers and other values to tweak your script code, or you'll change the HTML tags to provide different content
|