Basic HTML version of Foils prepared 23 June 1997

Foil 66 More on Document Objects -- Image

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo


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



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998