Array, Date, and Math, and a core set of language elements such as
operators, control structures, and statements.
supported by most of the modern browsers.
on the server, which supports it (Netscape LiveWire). It includes core
info on this see Netscape LiveWire
part of this course.
HTML page is inside:
Here is a simple example:
or learn from examples.
Note, that it's far from being a full reference, please consult
methods and objects.
Array - Provides the functionality to work with arrays
(have a properties like length, methods like sort,
reverse, concat etc.)
Date - Lets you work with dates and times.
Math - Has properties and methods for mathematical
constants and functions. For example have a properties like E, PI
and methods like abs, log, sin etc.
Button - Allows to work with buttons on an HTML form.
Properties like form, name, value and methods like click,
document - Contains information about the current
document, and provides methods for displaying HTML output to the user.
Properties like forms - array of forms on this document (objects),
cookie, images - array of images etc. You can do all kinds
of things with this object, e.g. if you want to change the first image
on your document from the empty_cart.gif to full_car.gif:
document.images.src = "full_car.gif";
Form - Lets you work with forms in the document.
Properties like action, elements - array with all form
elements (buttons, checkboxes, text fields etc.). Methods like
submit - submits the form, reset etc. Example: if you need
to submit the form from your function, just do form.submit()
History - Contains an array of information on the URLs
that the client has visited within a window. This information is stored in
a history list and is accessible through the browser's Go menu. Properties
like current, previous, methods like back, forward.
e.g useful if you want to send a user back ( window.history.back() )
Image - An image on your document. Useful if you want
to change the image from your script, e.g. rollover.
Location - Contains information on the current URL. Allows
you to access different parts of URL, doing reload etc. e.g. if you
want to send user to the new URL you can do something like:
window - Represents a browser window or frame. This is
the top-level object for each document. Have a lot of useful properties &
methods. Examples of usage: window2 = window.open(...); - opens the new window window.close(); - closes window window.confirm("Are you sure?"); - gets the confirmation from the
Note, since window is a top-level object for the client hierarchy, many
methods can be called directly, it'll be assumed, that these are the methods
of current window.
e.g. confirm("Are you sure?"); will work just fine.
It is also very useful in verifying the user's input. It can be pretty
frustrating for the user to submit the form with 10 fields just to find out,
that he forgot to put the zip code, press the back button and then see, that
he has to enter everything again... - Avoid it by checking such things
the user's convenience only, on the server side never trust the browser! See
more in security part for the
Sometimes you can even get some work done on the client-side.
e.g. if you
have a screen, where user chooses the items from the list of products, you
can calculate a total and update it each time, he/she adds or deletes an
item. Although, as it was said in the previous paragraph, don't trust these
scripting language and is not intended for the huge programs, so even though
you can write some big client-side application with this, it's not such a
good idea :-)