The document object has several important subobjects including Anchor, Applet, Area, Form, Image, and Link |
It also has arrays anchors, applets, forms, images, and links holding all occurrences of these objects for a particular document |
We have already illustrated Form and Link; here we look at Image |
The tag <IMG NAME="fred" SRC="jim.gif"> in an HTML file generates an object document.fred of type Image with property document.fred.src="jim.gif" |
One can preload an image using the statement: |
image1 = new Image(); image1.src = "henry.jpg"; |
and then change an image in the document using: |
document.fred.src = image1.src; |
Note the image is fetched from cache, so this is fast! |
This technique can be used for animated images, for example |