JavaScript tutorial - The JavaScript object

Navigation

Skip navigation.

Site search

Site navigation

JavaScript tutorial

Printing

Other tutorials

The JavaScript object

This page gives a list of objects, properties, collections and methods for documents and JavaScript components. This view of all properties available from the respective element types is referred to as the JavaScript object.

Some browsers may provide aditional properties or methods but as this stage of the tutorial is intended to teach you how to program so that your scripts work in all the possible (so called 4th generation) browsers, I have given those that are available in all possible browsers or those which have an alternative, which I will also have given. This is the last chapter of this tutorial where I will deal with such a wide range of browsers. In the next few chapters, I will abandon 4th generation browsers, and move on to the much more advanced DOM browsers (also known as 5th generation browsers).

Contents

Key

For items written in the format: 'methodName([someOtherStuff])', someOtherStuff is optional and does not need to be written. The [] brackets must be removed. For items written in the format 'methodName(type varName)', 'type' gives the type of variable expected by the method or collection, called varName in this case.

To use this structure to refer to any object, property, collection or method, treat each new branch level as a new child level. For example:

window.document.nameOfForm.nameOfInput.defaultValue = 'I love it';

Note, all collections also have the length attribute. Also note, window is often omitted when referring to child objects.

Standard document components

Positioned elements

In DOM and proprietary DOM browsers, this could actually be any element, not just one that is positioned. However, at this stage of the tutorial, only 4th generation DHTML is being discussed, and therefore this is referred to as a positioned element. The next chapter will show how this applies to all elements, not just those that are positioned.

Event objects

Intrinsic objects showing constructors

The constructors are all properties of the window object but they are almost always used without 'window.'. Syntax:

var variableName = new intrinsicObjectConstructor(options);

For example:

var myArray = new Array('here','there','everywhere');

Array

Boolean

Date

Note, a UNIX timestamp (milli) is the number of milliseconds since 00:00:00.000 01/01/1970.

Note also that UTC is the time as it would be in the GMT timezone, so GMT and UTC are equivalent.

Function

Image

Number

Object

Option

Regular Expression

String

Last modified: 1 April 2011

  1. Previous
  2. Next
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.