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 |