代码示例:(标识:dhtm_image_preload)
<html>
<head>
<script type="text/javascript">
img2=new Image()
img2.src="/static/demo/images/eg_landscape3.jpg" 
function changeImage()
{
document.getElementById('myImage').src=img2.src
}
</script>
</head>

<body>

<p>当您把鼠标移动到图片上时,会出现一幅新的图像。</p>
<img id="myImage" onmouseover="changeImage()" border="0" src="/static/demo/images/eg_landscape2.jpg">
<p>新图像会立即出现,这是因为您的浏览器已经加载了这幅图像。</p>

</body>
</html>
运行结果: