internet.com
Library
Magazines

webreference.com

Java Boutique

Search Engine Watch

PC Webopedia

The Web Developer's Virtual Library

   Library

Example on Preloading Images

This example preloads the second image within the <HEAD> section with the following code:

<script language = "JavaScript"> SecondAlien = new Image() SecondAlien.src = "alien2.gif" </script> Here is the image (move the mouse over the image to see the images switch):

Here's the code to switch the images.

Tip! Note the use of BORDER = "0" to eliminate the border you'd normally want for a hyperlink. Recall that in this case, we're only using the <HREF> tag so we can catch the onMouseover event.

<A HREF="javascript:void(0)" onMouseover="document.Alien.src=SecondAlien.src" onMouseout="Alien.src='alien1.gif'"> <IMG SRC='alien1.gif' BORDER="0" NAME="Alien" width = "75" height = "68"></A>
Web Developer® Site Feedback
Web Developer®
Copyright © 2000 internet.com Corporation. All rights reserved.

Web Developer® Home Over a dozen topics in detail Live Chat Downloads Book and Product Reviews Threaded Discussions How-To/Articles/Links Developer Daily News Subscribe Search Corporate Information Advertise Events Publications internet.com Home