[Home] | [Articles Index]

Beyond HTML with JavaScript

by Ted Kuik

If you want do more with your web site's pages than is possible with html alone, JavaScript is definitely a programming language to consider. It's free, does not require special server support (since it runs in the user's browser), and is widely supported by books, tutorial sites, and forums.

Uses and Limitations

JavaScript can be very useful for many tasks ranging from very simple to fairly complex. For example:

Javascript has a variety of date and time functions. You could have Javascript calculate the date, the time, the day of the month, or that today is TargetField perhaps adding some related text, as appropriate. (If, by some chance, the preceding sentence does not refer to the correct day of the week, it's probably because (1) your computer's clock is not set to the right date, (2) you don't have Javascript enabled in your browser, or (3) you are using a browser which does not support the date functions I used.)

Javascript can be used to create simple games, such as the trivia games which I've made available on this page. Of course, you can also use it to create more complex games.

Javascript has various graphics functions. You could use it to display a random picture or for something more intricate, such as The JavaScript Raytracer. In addition to being an impressive demonstration of the type of program that JavaScript is capable of, it's worth taking a peek at the source code of this application to gain some insight into how to use JavaScript for advanced graphics programming (and how ray tracers work).

Of course, like every programming language, JavaScript has its limitations. Among them:

Javascript can not write data to either the server or (with the exception of cookies) to the web site visitor's computer. This limitation is not all bad. Allowing code which a malicious user could potentially alter to have access to the server would be very bad from a security standpoint. Similarly, code which could write data to a user's computer would expose the user to potential security problems. JavaScript's inability to store data except with cookies, however, does render it unfit for certain types of programs.

As I alluded to earlier, if the user does not have JavaScript turned on in the browser, the Javascript programs will not run.

Different browsers often produce different results from the same Javascript code. It pays to test your JavaScript programs in all of the browsers you plan to support to make sure that the programs behave acceptably.

Learning Javascript

It's easier to learn JavaScripts if you are already somewhat knowledgeable in html. If you are not, however, you will likely become more so along the way, as any good book or tutorial on JavaScript will show you how it works with with html, thus teaching you that language as well.

There are many good books written about JavaScript. I've found the Microsoft Press book JavaScript(TM) Step by Step by Steve Suehring particularly useful.

Online resources for learning JavaScript abound as well. Some worth a look include:

Obviously the preceding examples are only a small subset of the many JavaScript sites available. If there is something in particular that you want to know about JavaScript, you can almost certainly find the answer online with a little patient searching. Happy learning!

 
 
 
 
 
 
 
 
 

Last Revised September 17, 2009

© Copyright 2009, Ted Kuik/Kuik Computer Services. All rights reserved.