Since we'll need some commands to get started, we'll begin with input and output. For now, we'll simply describe the commands. In the next section, we'll see how to incorporate them into a page.
One way to provide information to the user is with the
alert(text) function. This function brings up an
alert box which displays the argument to the function. Many
people find the alert box a simple way of providing a greeting
without "muddying" the underlying HTML.
A similar way to obtain information from the user is with the
prompt(request,default) function. This
function brings up a dialog box in which the user can type a
response. In most cases, you will want to include a default setting.
The function returns the string the user entered.
in HTML pages, you can also save them as
and load them into navigator. This is often useful for quick testing
<SCRIPT> tag. The tag has two optional
src parameter is particularly useful, as it lets
general functions, and then incorporate them into your program using
<script src="..."> tag.
things to you as objects, and lets you manipulate them as such. For example, you can refer to the current window as
the current document as
The pieces of information associated with an object are called the
properties of that object. A property may be a number, some text, or even another object). To refer to a property of an object,
you use the name of the object, a period, and the name of the
propety. For example, you can obtain the title of a document as
Objects also have associated functions, which are normally called
methods. These are the things that the object knows how to
do. For example, you could tell the document to close itself with
For certain types of predefined objects, such as
windows and arrays, you create a new object using the
This page written by Samuel A. Rebelsky.
This page generated on 42 by SamR's Site Suite.