A Brief Introduction to JavaScript

JavaScript is a relatively simple scripting language that enables the Web designer to add certain kinds of interactivity to Web pages.  It is not a computer programming language, but it shares some similarities with programming languages like Java, which it is derived from.

I won't go into the details about which browsers have JavaScript enabled, but if you have a JavaScript-enabled browser and JavaScript is turned on, then you should have been asked to enter your name when you accessed this page.

The home page of this course employs a JavaScript effect to change the appearance of the buttons when you position your mouse over them. Also, the quizzes on this site employ JavaScript.

JavaScript scripts are generally included directly in Web pages between these tags:

<SCRIPT LANGUAGE="JavaScript">

</SCRIPT>

The JavaScript script itself resides between the tags.  Browsers that do not support JavaScript will simply ignore what is between the tags (as they do with other tags which they don't recognize).

You can look at the source to this page to see what a JavaScript script looks like when it is embedded in a Web page among the HTML.

Much of the functionality of JavaScript comes from its abilitity to respond to "events," such as when the user clicks on a button or moves the mouse over a graphic or even when the user enters or leaves the Web page.

Here is a quick explanation of some of the more popular uses of JavaScript.

Pop-up windows
One of the things that JavaScript is good for is creating small pop-up windows that display information when the user clicks on a link.  Example

Alert boxes and confirmation boxes

Image Rollovers
The home page of this site employs a JavaScript rollover effect. Essentially, the script tells the browser to load some images into memory. Then when the user moves the mouse over one of the images, it is instantly replaced by another image.  The replacement image is a slight variation of the original image, so the user has the impression that the original image "lit up" or something similar. This is a very popular use of JavaScript to enhance a page by adding some interactivity.

Other uses of JavaScript

Sources of JavaScript
HotSyte--The JavaScript Resource
"Introduction to JavaScript" at the Web Designer's Virtual Library
The JavaScript Collection at HotWired's Webmonkey

Back to Module Three