Next page | Contents page |

Some useful objects

Document Object Model (DOM) level 0

It was mentioned on an earlier page that the DOM has progressed to level 4 at the time of writing. Here we consider the original level 0 version. Nowadays there are easier ways of doing things but this structure is still present.

Elements on an HTML page are represented by objects or arrays which can be accessed by the script. They are properties of an object called document, of class Document.

For example, if the page contains a hyperlink, written in HTML as <a name="abc" href="xyz">XYZ</a> then script can access this as document.links ["abc"] or as document.links [n] if this is the nth link in the page (counting from 0).

Some useful properties of the document object

Many of those are awkward to use because you would need to know the numbered sequence of objects on the page, so they are rarely used now. It is much simpler to use id attributes on elements you need to access, as we have been doing from the beginning of this course. The id technique was not available in the original DOM, used by early browsers.

Objects other than document

window represents the window in which the program is running.

location holds the URL from which the current page was loaded. Properties of this object include

navigator represents the browser and device in which the program is running.

screen has details of the physical screen.

history enables some navigation of the user's browsing history, such as going back but this is quite limited for security reasons.

Next page | Contents page |