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


1 The document object has several important subobjects including Anchor, Applet, Area, Form, Image, and Link
2 It also has arrays anchors, applets, forms, images, and links holding all occurrences of these objects for a particular document
3 We have already illustrated Form and Link; here we look at Image
4 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"
5 One can preload an image using the statement:
6 image1 = new Image(); image1.src = "henry.jpg";
7 and then change an image in the document using:
8 document.fred.src = image1.src;
9 Note the image is fetched from cache, so this is fast!
10 This technique can be used for animated images, for example

in Table To:


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