您可以使用图像对象的onLoad事件。类似这样的:
<html>
<head>
<script type="text/javascript">
function imageLoaded(imgId, url) {
alert(imgId);
var img = document.getElementById(imgId);
img.src = url;
}
</script>
</head>
<body>
<img id="bg" src="http://pupunzi.files.wordpress.com/2009/01/imgnav.jpg?w=350&h=285" alt="image" onLoad="imageLoaded('img1', 'http://forbiddenplanet.co.uk/blog/wp-content/uploads/2009/01/Adam%20Elliot%20Max%20and%20Mary%20animation.jpg');" />
<img id="img1" onLoad="imageLoaded('img2', 'http://pupunzi.com/images/components/mb.imageNavigator.png');" alt="image 1" />
<img id="img2" alt="image 2"/>
</body>
</html>
在这个例子中,我让警报让你看到如何加载前一图像时加载图像。