标签:
方法一:
1 <script type="text/javascript"> 2 var img01 = new Image(); 3 var img02 = new Image(); 4 var img03 = new Image(); 5 var img04 = new Image(); 6 img01.src = "img/1.jpg"; 7 img02.src = "img/2.jpg"; 8 img03.src = "img/3.jpg"; 9 img04.src = "img/4.jpg"; 10 </script>
缺点:如果加载图片较多,比较麻烦
方法二:
var images = new Array(); function preLoad() { for (var i = 0; i < preLoad.arguments.length; i++) { imgs[i] = new Image(); imgs[i].src = preLoad.arguments[i]; } } preLoad("img/1.jpg", "img/2.jpg", "img/3.jpg")
标签:
原文地址:http://www.cnblogs.com/yinzf/p/5901840.html