[Overview] [Basics] [More] [Fun] [Class 2] [If] [Functions] [Timing] [Queries] [References] [Examples] [Libraries] [Assignments]
Abstract: A short introduction to JavaScript, its purpose, and its alternatives. Does not provide any description of how to code in JavaScript.
JavaScript is a programming language developed by Netscape Communications Corporation to permit more interactive HTML pages. Why do we need JavaScript? HTML, the core language of the World-Wide Web, is a markup language: it describes what data are, and not how to manipulate those data. On the other hand, programming languages make it possible to mainpulate data. In effect, JavaScript was intended to extend HTML to make it more interactive.
What can you do with JavaScript? A great many things:
Because of JavaScript's great power, it is now being used as a core component of dynamic HTML, a ``hot new web technology'' of the instant (unless that instant has already passed).
The folks at Netscape tried to make JavaScript usable by novices, but also familiar to ``real programmers''. Hence, it started as a small language (for novices), but it looks a lot like the programming language C (for programmers). JavaScript is not designed for large programs, and does not always do well with such. However, it does suffice for many small and medium-sized tasks.
JavaScript takes ideas from both the imperative and object-oriented paradigms. If you know an imperative language, such as Basic, Pascal, or C, much of JavaScript will seem familiar, although the syntax may be different. In particular, it supports traditional imperative components, such as
However, JavaScript adds ``objects'' to the mix. In a sense, objects are groups of data and related functions (sometimes called ``methods''). Objects are similar to records in many imperative languages, although they are much more powerful. JavaScript also adds events and event handlers. In effect, you can write programs that say ``when this happens, do this''. However, you are limited in the events you can respond to. (There are many more objects in JavaScript 1.2; we won't discuss them.)
JavaScript is primarily used as a client-side language, in that JavaScript programs are part of HTML pages, with the JavaScript code being exectued by the browser. However, Netscape also allows the use of JavaScript for writing CGI scripts in their LiveWire server, permitting server-side JavaSript. This tutorial will cover only client-side issues.
Netscape introduced JavaScript with version 2.0 of their Navigator browser. That was JavaScript 1.0. As people began to develop programs and found deficiencies, Netscape extended and improved the language for version 3.0 of their Navigator browser, leading to JavaScript 1.1. With the release of Netscape Communicator (Navigator 4.0), JavaScript was extended to version 1.2
Because so many pages began to incorporate JavaScript scripts, Microsoft felt compelled to include support JavaScript in version 3.0 of their Internet Explorer browser. They call their version of JavaScript, JScript.
Unfortunately, the three versions of JavaScript differ somewhat in the commands and objects they support. In this tutorial, I'll be primarily covering topics from 1.1, the version supported by Navigator 3.0 (and mostly by 4.0).
JavaScript is not the only way to make pages interactive, although it is one of the most convenient. Alternatives include CGI, Java, VBScript, and some advanced features of HTML.
Before the proliferation of web languages, the primary mechanism for building interactive pages was CGI, the common gateway interface. With CGI, HTML pages can send information to programs that reside on servers, and the servers can generate new pages based on that information. CGI script are ideal for search engines and other applications in which data reside on the server. However, pages using CGI scripts are not fully interactive; in effect, the user simply visits a sequence of pages that remain static within the viewer. JavaScript, because it runs on the user's computer, allows much more dynamic pages. On the other hand, it cannot easily obtain information from a server.
Sun Microsystems developed Java as an ``industrial strength'' language for program development. They soon realized that it was also appropriate for including programs within web pages. However, Java programs are generally independent of the surrounding page: they cannot manipulate the page, and the page cannot manipulate the Java programs. (A combination of Java and JavaScript now permits some page/application communication.)
VBScript is Microsoft's alternative to JavaScript. It is somewhat more readable than JavaScript, and builds on an installed base of Visual Basic users and programmers. However, it is supported only by Internet Explorer. There have also been questions raised as to the security of using VBScript.
Until the development of those languages, some of the ``features'' of
a programming language needed to be supported by HTML (or variants
thereof) and the browser. For example, there are tags in HTML to load
another page after some time progresses, or to test for browser support
of some tags. For example, there is a
<noframes> tag for browsers that don't support
frames.
Because JavaScript is supported by both major browsers, it is the choice for many applications. Because Navigator and Communicator are now free (as, admittedly, is Internet Explorer), they make an appropriate platform.
[Overview] [Basics] [More] [Fun] [Class 2] [If] [Functions] [Timing] [Queries] [References] [Examples] [Libraries] [Assignments]
Source text written by Samuel A. Rebelsky.
This page may be found at http://www.math.grin.edu/~rebelsky/Tutorials/JavaScript/Spring1999/aboutjs.html
Source text last modified Mon Apr 12 13:07:08 1999.
This page generated on Mon Apr 12 13:13:14 1999 by SiteWeaver. Validate this page's HTML.