Que Logo

Chapter 5

Off and Running… with Someone Else's Help



In This Chapter

The Best Way To Learn


Starting up the learning curve with anything can be a major task, and computer-related things always seem to be the worst. After gathering up your courage to actually begin, you have a pile of books, the computer screen blinking "unknown command" at you, and a growing frustration with the inhabitants of Silicon Valley. Computer languages can be very frustrating.
To try to take the edge off the process and "ease" your way into the world of JavaScript, take a page from some of the computer gurus that wander the Web:
In other words, borrow from those who've already gotten the bugs out. No, this is not plagiarism, since I'm not suggesting that you simply take someone else's hard work and put your name on it. Rather, look at the script code that they wrote and use what they did to help you better understand how JavaScript interacts with the Web. If you want to try to play with the script (make your own changes), all you have to do is save the HTML document as a file on your computer.
But, before you can learn from the experts, you have to find them.

Where Are They?


With the explosion of JavaScript on the Web today, several sites have sprung up (literally overnight) that make excellent starting points for you to explore further. In this chapter, you'll take a quick tour through several of the newest, neatest, and best places to learn more about JavaScript_and you'll pick up a little more info on Java, JavaScript's big brother.
So… do you have Netscape Navigator 2.0 installed? Good. Log into your Internet provider, fire up Netscape, and start surfin'. The tour is ready to depart-JavaScript style!

Netscape: The "Good" Got "Better"


Point your browser at:
http://home.netscape.com/comprod/products/navigator/version_2.0/index.html
You'll be whisked into the world of Netscape and Netscape Navigator 2.0, the company that developed JavaScript. Netscape Navigator has been the most popular World Wide Web browser on the Internet to date, and with JavaScript, it's going to be in the forefront for some time to come.
Netscape's pages change regularly, so you'll want to stop back from time to time to catch the latest information and updates to Navigator and the other products Netscape sells.
Finding your way from the Netscape Navigator 2.0 page to JavaScript information takes a few clicks. From the opening page, you have two equal paths. In the upper (larger) window, you can scroll down through the list of Navigator features until you see the link to JavaScript. Alternatively, the small frame at the bottom of the window contains a series of icons. Scroll to the right until you reach the Scripting icon (a typewriter).
From there, you will land smack-dab on the JavaScript page, wherein lie several examples of code, and a link leading to the "official" JavaScript documentation.

Eyeing Some Code


Earlier I suggested that you take a long, hard look at other authors' JavaScript programs. Doing so requires that you first store a copy of the program itself, so let's see how you do that-it's relatively painless.
Several example JavaScript programs are on the Netscape JavaScript page. One of them is an "Interest Calculator," which calculates interest on a loan based on data the user inputs into the table.

That's gonna cost ya. Calculating loan payments--oh, the fun!



Caveat Capture

There is one exception to everything we've said about capturing the JavaScript code from a page. It all assumes that the code was embedded directly into the HTML. Some authors may keep the code in a separate file, using the SRC= attribute of the <SCRIPT> tag. In these cases, you can't retrieve the JavaScript program code.
Because JavaScript code is embedded within the HTML, merely save the HTML code for this page, and you will find the JavaScript program within it. You can easily see the HTML code by choosing the Navigator menu option: View, Document Source. Depending on what source viewer you've configured, you may or may not be able to save the file right from there. If you can't, you can simply select the Navigator option: File, Save As. This pops up a Save File dialog box, in which you can select where to save the file. Be sure you selected HTML file in the Save as Type selection of the dialog box, as pictured on the next page.
The resulting file, with the name "somefile.htm" or "somefile.html" (depending on your system), is viewable by any text editor. It is simply a plain text file, and within it, you will find all the HTML tags that defined the page, including any JavaScript programs.

Gamelan


Before Gamelan, there wasn't a central clearinghouse for Java and JavaScript material. Now, if you set your browser to
http://www.gamelan.com/
you'll find an excellent collection of JavaScript pages, Java applets, and other Java-related nifties. The folks at EarthWeb (who maintain Gamelan) are updating the site daily, so there is always something new to check out. Gamelan breaks Java applets down into categories, and the areas covered are rather diverse: animation, communications, finance, games, special effects, networking, and so on. There's also an impressive list of links to other Java and JavaScript sites around the Net. At last glance, there were over 180+ sites in Gamelan's listing alone!
While you're poking around Gamelan, you might want to check out the Java Message Exchange (you'll find it listed in the sites category). The Message Exchange is a message board for the purpose of exchanging information on Java, JavaScript, and new Java/Script sites.

Gamelan: Learn to pronounce it right, and you're on your way to geekdom!

JavaScript Index


While Gamelan is Java-generic (it covers both Java and JavaScript), the JavaScript Index is devoted to JavaScript and its uses. Check out
http://www.c2.org/~andreww/javascript/
and you'll find a comprehensive categorical breakdown of JavaScript pages and implementations. Some are pure JavaScript; others merge JavaScript with Java and other HTML techniques.
One of the nice sections found on the JavaScript Index is its Widgets section. Widgets are little gadgets that do various things. From the standpoint of JavaScript, a widget is a little script that does something nifty: a scroll bar, a background changer, a pop-up help display. Widgets make great little scripts that you can borrow and put together with
other scripts to create truly unique Web pages.
To borrow a widget, simply follow the same procedures outlined earlier with the Netscape example: go to the page with the JavaScript program, and then save the HTML source-either by viewing the source and saving it from there, or by using the File, Save As option from the Navigator menu.

The JavaScript Index: Just for us JavaScripters.

Dimension X


No discussion of Java and JavaScript would be complete without mentioning the innovative crew of Dimension X. You can check them out at
http://www.dimensionx.com/dnx/java.html
Primarily focusing on Java rather than JavaScript, Dimension X is worth a peek, if for no other reason than to see what they've done with Java's graphics power. They're also in the process of developing several packages designed to make creating three-dimensional graphics in Java a snap. So if you're into cool graphics, these guys are worth keeping an eye on.
This is just the tip of the iceberg. More and more sites are appearing every day. So many, in fact, that it's becoming harder and harder to keep up with them. But, if you want to do a little one-stop shopping, you can check out
http://www.winternet.com/~sjwalter/javascript/
You'll find links to other sites, new and cool scripts, nifty tidbits and tutorials on Java and JavaScript-and a chance to give me a piece of your mind.

Sample Platter:What You're Likely To Find


Now that you know where to look for lists of JavaScript-powered pages, here's a sampling of the many diverse things those pages can do.
JavaScript 1040EZ Just in time for April 15, here's a site that uses JavaScript to fill out the 1040EZ (known by some wags as "1040 STU-PID") form.
http://www.homepages.com/fun/1040EZ.html
You have a company known as Home Pages to thank for this little marvel.
Unit Conversion Calculator These few nifties can convert from various units of measurement to others, all with the magic of JavaScript, authored by Jonathan Weesner.
http://www.cyberstation.net/%7Ejweesner/conv.html
Mastermind If you have any idea how to play the game Mastermind, JavaScripted by Ian Cameron, then this page might appeal to you.
http://dingo.uq.edu.au/~zzdcamer/master.htm
The Game of Nim A battle of wits; take on the Towers of Hanoi puzzle, you vs. JavaScript, as coded by Raul Garcia.
http://www.primenet.com/~raul/nim/nim2.htm
ColorCenter This nifty JavaScript incarnation allows you to test various Web page color combinations-a quick way to decide what colors will work in your own design. By Bill Dortch of hIdaho Design.
http://www.hidaho.com/colorcenter/
Scrolling Text and Banners Some textual animation for those with a sweet tooth for eye candy; this script is the spawn of Craig Slagel.
http://www.boots.com/~craigel/java2.htm
SuperSearch A JavaScript tool that allows the user to simultaneously submit search data to several Web search engines.
http://www.wineasy.se/robban/seek1.htm

The Least You Need To Know


You've taken a whirlwind tour around the globe and through the Internet, and have found that Java and JavaScript are expanding at an explosive rate. You've seen that there are hundreds of sites (more and more springing up each day) with scripts and applets that you can download and use or adapt to your own needs. You also learned that using someone else's scripting ideas as a basis for your own is as simple as saving the script document and editing it.
Now that you have a few scripts from other JavaScripters, you're probably wondering what the devil those new lines in the script actually mean. That's what the next chapters cover: the inner workings of JavaScript.

Previous Chapter

Next Chapter


Beginning of ChapterTable of ContentsBook Home PageQue Home Page


For comments or technical support for our books and software, select Talk to Us.
To order books, call us at 800-716-0044 or 317-228-4366.

© 1996, QUE Corporation, an imprint of Macmillan Publishing USA, a Simon & Schuster Company.