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 arrays holding all the occurrences of these objects in a particular document.
|
We have illustrated Form and Link already -- here we look at Image
|
<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 images using syntax like:
-
image1 = new Image(); image1.src = "henry.jpg";
-
and then change Image in document using
-
document.fred.src = image1.src;
-
henry.jpg is fetched from cache and so this is fast!
|
This technology can be used for animated images and also to quickly change a picture displayed in perhaps an online shop catalog where user chooses a new item in a form.
|