JavaScript can make your pages better

Posted on April 9, 2004

In the beginning, the Internet gods created hypertext markup language. This language, known to you and me as HTML, was pretty much the sole programming possibility in the earliest development stages of the World Wide Web.

But HTML had many limitations, considering it is completely static and has no vowels or curved letters in the acronym. People developed ways to send forms, run their own applications and make tacos using different languages. Perhaps the most flexible and easiest to use of the extra Web languages was JavaScript. Some found ways to manipulate JavaScript to do just about anything, with the exception of bowling a 300 game, and they were happy. Thus the Internet gods rested for a few minutes then devised ways to show the date and time and make popup windows appear, all without ever locking their keys in the car.

The history of JavaScript is not all that complex. It was born as LiveScript in 1994, but soon after, the birth certificates were found to be forged. Netscape took control under the new name, while Microsoft developed its own language -- Vbsscript -- and started using a version of JavaScript called JScript. Instead of going separate ways, Internet companies decided to make a compatible scripting language called ECMAScript, which was adopted as standard in 1998. ECMAScript was JavaScript1.1 and has since been modified to 1.2.

It's important to remember JavaScript is not the same thing as Java. Even though both use code similar to the C language, Java must be compiled before you use it, while JavaScript is scripted directly on the page and can even be embedded. Although many JavaScripts can be complex, they are usually a bit more compact than entire Java programs.

The coolest thing about using this language is you really don't have to know much about it to apply the effects. There are numerous free script sites out there, one of the largest being The JavaScript Source. The site has many scripts divided into categories like background effects, calculators, forms, games, etc., so you don't have to waste time trying to find something you want. The JavaScript source shows the scripts in action and lets you copy and paste it into your existing HTML document.

There are two parts to most of the scripts: code that goes in the header of your document and code that goes in the body. If the JavaScript is complex, there's a good chance the bulk of it will exist in the header. There you will define functions, variables and anything you want the script to perform. Then within the document body you can call upon those thongs that are located in the header. HTML recognizes any type of script by utilizing the script language tag. Another thing most developers do is place their code inside of comment tags. Old browsers do not understand JavaScript, so if you do not put the code in comment tags, it could appear on the page. Most start with the code &lt!-- Begin and end it with // End --&gt. Imagine how much sense that makes!

When you are ready to make your own script, visit WDVL for a tutorial about JavaScript. You'll be a pro after that, I know it.

If you have reached the end of this column wondering, "if he's trying to be funny, he's doing a pathetic job," then maybe you'll want to check out a few of these free games from JavaScript Source:

* Battleship : next to Sorry and Chutes and Ladders, one of the classics. Sorry, it doesn't include sounds for Talking Battleship, but I'm sure you can make your own.

* Blackjack : don't spend too much time playing this one: my computer has been known to reach into my pocket and take some of the money I owe.

* Connect 4 : a great game for two people to play. The computer even keeps track of who wins the games.

There are plenty more, just check out the site and put some of those JavaScripts on your Web pages as well. The Internet gods will praise you.