JavaScript is an object-oriented (or, as some would argue, object-based) language.
An object is a set of variables, functions, etc., that are in some way related. They are grouped together and given a name
Objects may have:
Properties | ||
A variable (numeric, string or Boolean) associated with an object. Most properties can be changed by the user. | ||
Example: the title of a document | ||
Methods | ||
Functions associated with an object. Can be called by the user. | ||
Example: the
alert() method |
||
Events | ||
Notification that a particular event has occurred. Can be used by the programmer to trigger responses. | ||
Example: the onClick() event. |
Internet browsers contain many objects. In the last few years the object structure of internet browsers has become standardised, making programming easier. Prior to this, browsers from different manufacturers had different object structures. Unfortunately, many such browsers are still in use.
The objects are arranged into a hierarchy as shown below:
The Document Object Model. Objects shown in green are common to both Netscape Navigator and Internet Explorer; objects shown in yellow are found only in Internet Explorer while objects shown in blue are found only in Netscape Navigator.
The hierarchy of objects is known as the Document Object Model (DOM).
Window
is the fundamental object in the browser. It represents the browser window in which the document appears
Its properties include:
The Document object represents the HTML document displayed in a browser window. It has properties, methods and events that allow the programmer to change the way the document is displayed in response to user actions or other events.
Document properties include:
When you create a form in an HTML document using the <form>
and </form>
tags, you automatically create a form object with properties, methods and events that relate to the form itself and to the individual elements within the form (e.g., text boxes, buttons, radio-buttons, etc.). Using JavaScript, you can add behaviour to buttons and other form elements and process the information contained in the form.
Form properties include: