background
|
|
RiscOS
Risc OS Info
All you need to know about Risc OS and more.
More icon

bonsai
The Element
A small area for Bonsai related material.
More icon
|
|
Up Image
Navigation
Search this Site
Enter your search terms

Site Breadcrumb - You are here
|
Thau's JavaScript Tutorial
Lesson 5

by Thau!

Page 1 — Intro to Lesson 5

Now that you've mastered the basics of computer programming, it's time to refocus on the Document Object Model (DOM). We've already seen that the DOM hierarchy starts with a Window object. Inside each Window object is a Document object. We'll be spending this lesson going through the Document object and seeing how it can be used to get all kinds of information from your users and to dynamically present new information.

We've already had a good look at one of the properties of the Document object, the Images array. If you remember back to Lesson 4, the first image in a document can be modified by changing its src property. For example,

window.document.images[0].src='some_new_picture.gif';
will change the first image in a document to the GIF called some_new_picture.gif. As you might have guessed, each Image in the Image array is itself an object in the DOM. That's why images[0].src works. It's saying, get the Image object image[0] from the Images array and set its src property. The whole statement above reads in English, "get the document property of this window, get the first image from the document's image array, and change its source property to some_new_picture.gif."

The Image object has lots of other interesting properties. For example, you can have your JavaScript check to see if an image has been completely loaded before doing anything. However, these interesting properties will have to wait for later lessons. Gotta keep you coming back somehow, right? Today, we'll be focusing entirely on forms and how to use them in JavaScript.

next page»