码迷,mamicode.com
首页 > 编程语言 > 详细

每天一个JavaScript实例-判断图片是否加载完成

时间:2014-10-25 02:04:24      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   java   on   2014   art   log   

<!doctype html>
<html lang="en">
	<head>
  	<meta charset="utf-8">
    <title>每天一个JavaScript实例-判断图片是否加载完成</title>
    <script>

   
    window.onload=  function(){
 
   			//clearTimeout(clock);
			alert("加载完成");
		
	}
		var item = document.getElementsByTagName("img");
		
		var clock = setTimeout(function(){
			//var item = document.getElementsByTagName("img");
			//console.log(item);
			//console.log(item.item(item.length-1).onload);
		 	if(item.item(item.length-1).onload == null){
    	 	alert("还没加载完成呢!");}
    	 },1000)
    
    
    </script>
   </head>

	<body>		
    <img src="http://i1.hoopchina.com.cn/blogfile/201401/13/BbsImg138957793449615_500*311.jpg" />			
    <img src="http://www.xyzwallpaper.com/wp-content/uploads/2014/07/girl-wallpaper-300x300.jpg" />		
    <img src="http://www.xyzwallpaper.com/wp-content/uploads/2014/07/girl-wallpaper-2-300x300.jpg" />							 
    <img src="http://www.xyzwallpaper.com/wp-content/uploads/2014/07/girl-wallpaper-3-300x300.jpg" />		
    <img src="http://www.xyzwallpaper.com/wp-content/uploads/2014/07/girl-wallpaper-4-300x300.jpg" />		
    <img src="http://bestpaperz.com/data_images/out/40/8903786-shakira-in-the-chair.jpg" />		
    <img src="http://bestpaperz.com/data_images/out/40/8903770-red-currant.jpg" />		
    <img src="http://i1.hoopchina.com.cn/blogfile/201401/13/BbsImg138957793449615_500*311.jpg" />		
    <img src="http://bestpaperz.com/data_images/out/40/8903733-failed-surfing.jpg" />		
    <img src="http://bestpaperz.com/data_images/out/40/8903738-robert-pattinson.jpg" />		
    <img src="http://i1.hoopchina.com.cn/blogfile/201401/13/BbsImg138957793449615_500*311.jpg" />		
    <img src="http://bestpaperz.com/data_images/out/40/8903728-empty-bench.jpg" />		
    <img src="http://i1.hoopchina.com.cn/blogfile/201401/13/BbsImg138957793449615_500*311.jpg" />		
    <img src="http://bestpaperz.com/data_images/out/40/8903801-snow-park.jpg" />		

	</body>
	</html>		

每天一个JavaScript实例-判断图片是否加载完成

标签:blog   http   io   ar   java   on   2014   art   log   

原文地址:http://blog.csdn.net/waiting7436/article/details/40439971

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!